bash脚本:在命令中发送命令

bash脚本:在命令中发送命令

我想创建一个连接到服务器并在该服务器上运行 jupyter 笔记本的 bash 脚本。

当我使用 bash 脚本连接到服务器时,如何运行 jupyter notebook 命令?

我使用这个脚本:

#!/bin/bash
ssh [email protected] 
jupyter notebook --port 9999

当我运行脚本时,我使用命令连接到服务器,但该命令仅在我手动关闭与服务器的连接后运行。ssh [email protected]jupyter notebook --port 9999

jupyter notebook --port 9999连接到服务器后如何运行?

谢谢

答案1

您应该只编写要在远程服务器上运行的命令,如下所示:

ssh [email protected] 'jupyter notebook --port 9999'

您可以使用以下格式在远程服务器上使用 ssh 运行命令

ssh user1@server1 command1
ssh user1@server1 'command2'
ssh user1@server1 'command1 | command2'

相关内容