简体   繁体   English

如何让 Bash 脚本在另一个终端窗口的后台运行命令?

[英]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.

相关问题 Mono:如何在新的控制台/终端窗口上运行 bash 命令? - Mono: how to run a bash command on a new console/terminal window? 关闭终端窗口后如何运行特定的bash shell脚本? - How to run a particular bash shell script after closing a terminal window? 如何在终端中执行 bash 脚本? - How do I execute a bash script in Terminal? 如何将Ruby脚本制作为bash命令? - How do I make a Ruby script into a bash command? 如何使用 bash 脚本在 linux 中创建命令? - How do I make a command in linux using a bash script? Bash 脚本如何远程运行命令然后退出远程终端 - Bash script how to run a command remotely and then exit the remote terminal 如何将bash脚本作为命令运行? - How do you run bash script as a command? 在bash脚本中从当前终端运行命令 - Run command from current terminal in bash script 如何在具有“for”和“R”代码的服务器中运行 bash 脚本,我可以退出终端并且不会终止进程? - How do I run a bash script in a server with `for` and `R` code that I can exit the terminal and does not kill the process? 如何在 bash 中创建一个“停止”脚本来关闭我之前使用不同的 bash 脚本打开的 gnome 终端选项卡? - How do I make a "stop" script in bash that closes gnome-terminal tabs that I had previously opened with a different bash script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM