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

偶尔善良 提交于 2019-12-05 06:36:57

Try using the -f option of csh to disable the reading of the .chsrc and .login files:

    {"/bin/csh", "-cf", "echo hello"}

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.

Quoth the documentation for java.lang.Process:

"The methods that create processes may not work well for special processes on certain native platforms, such as native windowing processes, daemon processes, Win16/DOS processes on Microsoft Windows, or shell scripts. The created subprocess does not have its own terminal or console."

Perhaps you would like the java.lang.ProcessBuilder, instead.

Shervin Asgari

Have you look here. I managed to run some commands like this

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!