我环顾四周,因为我本以为这是一个相当普遍的问题,但是似乎没有什么对我有用。
基本上,我试图通过SSH连接到设备(Raspberry Pi)中来运行进程。该过程是node ./bin/www
。我写了一个publish.sh
脚本,在此之前可以做一些事情,但是当我运行命令时,ssh user@hostname "cd <my-location>;node ./bin/www
它分别在我当前的bash shell中启动了该过程。
我要做的是打开一个新的bash shell来运行该命令,因为该过程将启动Web服务器。
我尝试将ssh
命令包装在其中,bash -c 'ssh ...'
但它仍在publish.sh
启动脚本的外壳窗口中运行。我在做错什么吗?在shell脚本中,要在新的bash shell进程中运行命令,我到底需要做什么?
谢谢!
您可以ssh
与-n
选项一起使用,
ssh -Xn user@hostname <command> <argument>
使用-X
是可选的,以转发X11。就你而言
ssh -n user@hostname node ./bin/www
示例:要使用gedit
,在远程计算机中打开文本文件(file.txt),
ssh -Xn user@hostname gedit file.txt
从 man ssh
-n A common trick is to use this to run X11 programs on a remote machine. For example,
ssh -n shadows.cs.hut.fi emacs & will start an emacs on shadows.cs.hut.fi, and the X11 connection will be
automatically forwarded over an encrypted channel. The ssh program will be put in the background.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句