我如何在脚本内打开一个新窗口,用ssh切换到其他用户并运行命令?

问题描述 投票:0回答:1

0我想使用minicom或ssh连接打开一个新终端,并使用Shell脚本在该新窗口中与其他用户一起运行命令。我在shell脚本中尝试编写以下命令:

#! /usr/bin/tcsh -f

set Flag1 = 1
while ($Flag1)
   if ($Flag1)then 
          `xterm -e /home/Script/First.sh`
          set Flag1 = 0
   endif 
end
cat /home/Script/First.sh
#! /usr/bin/tcsh -f

sudo minicom -D /dev/ttyUSB0 
ifconfig eth0 10.120.140.3
ping -w20 10.120.140.1

第一个命令(minicom)有效,但没有继续执行其他命令。

xterm
1个回答
0
投票

我不知道我是否正确理解,但是如果要使用cmd1 && cmd2接连执行一个命令因此,如果您想在ssh连接后执行exec命令:

minicom... ssh tal@ip 'ifconfig && ping'

并将shebang添加为脚本的第一行:

#!/bin/sh
© www.soinside.com 2019 - 2024. All rights reserved.