简体   繁体   English

如何同时打开ssh和启动命令?

[英]How to open ssh and launch a command at the same time?

I have an application (Java, but could be anything else) which needs to launch another application. 我有一个需要启动另一个应用程序的应用程序(Java,但可以是其他任何东西)。 This is not on the same machine. 这不在同一台计算机上。

Manually, I would launch the application in this way: 手动地,我将以这种方式启动该应用程序:

ssh myself@machine -X
/..../myapplication

I tried to put the two commands in a text file called mycommand and 我试图mycommand两个命令放在一个名为mycommand的文本文件中,

source mycommand

...but the second command will be executed on the local machine just after having closed the SSH section. ...但是第二个命令将在关闭SSH部分后立即在本地计算机上执行。

Do you know if there is a way to open an ssh and launch an application from the other machine at the same time without the user intervention? 您是否知道有没有一种方法可以在无需用户干预的情况下同时打开ssh并从另一台计算机启动应用程序?

If after the command you don't need to execute other command in the SSH shell, you can use the following command 如果在执行该命令后无需在SSH Shell中执行其他命令,则可以使用以下命令

ssh myself@machine -X myapplication

The shell will execute the command and then close the ssh connection Shell将执行命令,然后关闭ssh连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM