简体   繁体   English

如何从另一个Shell脚本调用Shell脚本?

[英]How to call the shell script from another shell script?

I have written 2 scripts which opens the vncviewer of 2 hosts.and i have another 1 script that calls both the scripts.but when I call the main script the 1st vncviewer opens and after closing the window, the 2nd vncviewer is opening..but I want to run both scripts simultaneously..how to do this? 我已经写了2个脚本,可以打开2个主机的vncviewer。我还有另一个1个脚本,可以同时调用两个脚本。但是当我调用主脚本时,第一个vncviewer打开,关闭窗口后,第二个vncviewer正在打开..但是我想同时运行两个脚本..如何做到这一点?

Here are the scripts involved: 以下是涉及的脚本:

22.sh 22.sh

#!/bin/sh 
# 
host='192.168.2.22' 
vncviewer $host --viewonly 

25.sh 25.sh

#!/bin/sh 
# 
host='192.168.2.25' 
vncviewer $host --viewonly 

main script that calls 2 scripts 调用2个脚本的主脚本

#!/bin/sh 
# 
./22.sh 
./25.sh 
sh -x 22.sh & 
sh -x 25.sh &

You need to background the first invocation of vncviewer . 您需要将vncviewer的第一次调用作为背景。 Use & after the command for this. 为此,请在命令后使用&

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

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