簡體   English   中英

如何讓 Bash 腳本在另一個終端窗口的后台運行命令?

[英]How do I make a Bash script run a command in the background in another Terminal window?

我是 bash 腳本的新手,我需要制作一個運行以下命令的腳本:

service apache2 start
airmon-ng start wlan0
airbase-ng -e FREEINTERNET -c 1 -P wlan0mon
ifconfig at0 192.168.1.129 netmask 255.255.255.128
route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.129
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables --table nat --append POSTROUTING --out-interface wlan1 -j MASQUERADE
iptables --append FORWARD --in-interface at0 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.0.4:80
iptables -t nat -A PREROUTING -p tcp --destination-port 443 -j REDIRECT --to-port 80
iptables -t nat -A POSTROUTING -j MASQUERADE
dhcpd -cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid at0
service isc-dhcp-server start

我最大的疑問是如何讓腳本在不同的終端中打開airbase-ng -e FREEINTERNET -c 1 -P wlan0mon命令並繼續執行airbase-ng -e FREEINTERNET -c 1 -P wlan0mon和其余命令。 我在 GNOME 中使用 Kali 64 位。

您可以通過后綴&來在后台運行某些內容。 如果您想在新的 GNOME 終端窗口中運行某些內容,您可以使用gnome-terminal -e 將它們放在一起,在新的 GNOME 終端窗口中運行您的airbase-ng命令,同時讓您的腳本的其余部分繼續運行:

# …
airmon-ng start wlan0
gnome-terminal -e 'airbase-ng -e FREEINTERNET -c 1 -P wlan0mon' &
ifconfig at0 192.168.1.129 netmask 255.255.255.128
# …

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM