![](/img/trans.png)
[英]Open new gnome-terminal from scripts and input vars from present script.
[英]Bash script. Open new terminal and run command
如何從bash在新終端中運行命令? 如果僅從一個終端運行,則mosquitto_sub
阻止腳本。 xterm -e
打開新終端,但我的腳本也被阻止...
#!/bin/bash
COUNTER=0
xterm -e mosquitto_sub -h 192.168.1.103 -t test
mosquitto_pub -h 192.168.1.103 -t test -m "Connected"
cd Desktop/ScreenTool/image/
while [ $COUNTER == 0 ]; do
tesseract c.png output
if grep -q Click "/root/Desktop/ScreenTool/image/output.txt"; then
mosquitto_pub -h 192.168.1.103 -t test -m "Rain is here"
echo -en "\007"
fi
cat "/root/Desktop/ScreenTool/image/output.txt"
sleep 3;
done
要在不等待命令完成的情況下執行命令,請使用&
將其放在后台。
#!/bin/bash
COUNTER=0
xterm -e mosquitto_sub -h 192.168.1.103 -t test &
mosquitto_pub -h 192.168.1.103 -t test -m "Connected"
cd Desktop/ScreenTool/image/
while [ $COUNTER == 0 ]; do
tesseract c.png output
if grep -q Click "/root/Desktop/ScreenTool/image/output.txt"; then
mosquitto_pub -h 192.168.1.103 -t test -m "Rain is here"
echo -en "\007"
fi
cat "/root/Desktop/ScreenTool/image/output.txt"
sleep 3;
done
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.