在java中运行ssh命令时出错
我正在尝试以这种方式在 Eclipse 中运行 ssh 命令
ExpectJ exp = new ExpectJ();
Spawn s = exp.spawn("ssh [email protected]");
. . .
. . .
. . .
但是我得到了这个错误 -
Pseudo-terminal will not be allocated because stdin is not a terminal.
如果我尝试按照以下方式执行
Spawn s = exp.spawn("ssh -t -t [email protected]");
并执行,我也会收到此错误
tcgetattr: Invalid argument
,代码只执行一半并且我收到此消息 -
Killed by signal 15.
并且最后我面临超时异常
有什么建议吗?我不确定这些错误消息的含义。
I'm trying to run ssh command in Eclipse this way
ExpectJ exp = new ExpectJ();
Spawn s = exp.spawn("ssh [email protected]");
. . .
. . .
. . .
But i get this as the error-
Pseudo-terminal will not be allocated because stdin is not a terminal.
If i try doing it the following way,
Spawn s = exp.spawn("ssh -t -t [email protected]");
and execute,i get this error
tcgetattr: Invalid argument
also,the code executes only half and i get this message-
Killed by signal 15.
and finally i face a timeout exception
Any Suggestions? I'm not sure what those error messages mean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定为什么你会遇到你所看到的错误,但我可以说当我需要执行 ssh/scp 等时。我使用过这个库: http://www.jcraft.com/jsch/ 它对我来说非常有效。
I'm not sure why you're getting the errors you're seeing, but I can say when I've needed to do ssh/scp etc. I've used this library: http://www.jcraft.com/jsch/ and it's worked very well for me.
我可以使用内置方法!从来没有意识到甚至存在。
I can use the in-built method!! Never realized that even existed.