How can I run an application on a remote machine by ssh?

谁说胖子不能爱 提交于 2019-12-04 20:06:41

For future readers: As shown by the discussion, the reason was that JSch connected to a different server than normal SSH (and one of these had the file, while the other one had not). I still let my answer here, as it contains some useful (I think) debugging ideas for similar problems. But remember: First check that you are connecting to the right computer.


In principle, this is the way to do it, if you use JSch. If you get the error message bash: myapplication: command not found, this means that there was no myapplication binary in the path. (And you will get the same error message when using plain command line ssh.)

Try which myapplication (or type myapplication) in your normal shell, to see where it is located. Then use echo $PATH >&2 as the command, to see the path used by your exec channel. It could be that this is different then when executed from your normal shell. If so, either use the full path in the command name, or fix your setup. (Look wether the path is set in ~/.bashrc, ~/.profile, /etc/profile or /etc/bash.bashrc. Only some of these files will get executed on a interactive versus noninteractive login - and exec channel will be noninteractive, I think.)

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