Invoking shell from java, it complaints "stty: standard input: Invalid argument"

solotim picture solotim · Mar 29, 2010 · Viewed 22.5k times · Source

I invoke a shell command by Process class from java and it prints

"stty: standard input: Invalid argument" 

no matter whether the command is right or wrong (normal output of shell command is shown too). If I run the shell command in shell, no such error message is shown.

The command is something like this: {"/bin/csh", "-c", "echo hello"}

Answer

Jonathan Feinberg picture Jonathan Feinberg · Mar 29, 2010

You are invoking the stty command from your .profile, or .bash_profile. You'll have to redirect its standard error to /dev/null.

stty blah blah blah 2>/dev/null

stty can't deal with the pseudo-tty that Java provides in shelling out.