[英]How do I make a Bash script run a command in the background in another Terminal window?
I'm new to bash script and I need to make a script that runs the following commands:我是 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
My big doubt is how to make the script open the airbase-ng -e FREEINTERNET -c 1 -P wlan0mon
command in a different terminal and keep executing both airbase and the remaining commands.我最大的疑问是如何让脚本在不同的终端中打开
airbase-ng -e FREEINTERNET -c 1 -P wlan0mon
命令并继续执行airbase-ng -e FREEINTERNET -c 1 -P wlan0mon
和其余命令。 I'm using Kali 64-bit with GNOME.我在 GNOME 中使用 Kali 64 位。
You can run something in the background by suffixing it with &
.您可以通过后缀
&
来在后台运行某些内容。 If you want to run something in a new GNOME Terminal window, you can do so with gnome-terminal -e
.如果您想在新的 GNOME 终端窗口中运行某些内容,您可以使用
gnome-terminal -e
。 Putting those together, to run your airbase-ng
command in a new GNOME Terminal window while letting the rest of your script continue to run:将它们放在一起,在新的 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.