我如何开始bash脚本在新终端的命令 [英] how do i start commands in new terminals in BASH script

查看:185
本文介绍了我如何开始bash脚本在新终端的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的bash脚本中的几个变量读取,然后运行airodump中我的家庭网络。我想保持窗口airodump中运行并打开一些新的终端运行网络发现其他命令而airodump中屏幕打开(这样我就可以看到效果)。结果
现在我有什么看起来像这样(编辑为简洁起见):

my bash script reads in a few variables and then runs airodump on my home network. I would like to keep the window with airodump running and open some new terminals to run other commands for network discovery while the airodump screen is open (so i can see the results).
right now what i have looks like this (edited for brevity):

#!/bin/bash
read -p "Enter the channel: $channel"
airomon-ng start wlan0 $channel,$channel
airodump-ng -c $channel,$channel mon0 &&
terminator -e netstat -ax &&
terminator -e nmap 192.168.1.1

这是使用整个终端(airodump中)第一个命令启动了罚款,我可以看到网络,但它只是停留在该屏幕上。如果我CTRL + C,然后它可以追溯到提示,但我可以看到错误:用法:终止[选项]错误没有这样的选择结果
我想了netstat和NMAP命令出现,并留在自己的终端窗口,我怎么能这样做呢?

the first command that uses the whole terminal (airodump) starts up fine and i can see the network, but then it just stays on that screen. If i ctrl+c then it goes back to prompt but i can see the error : Usage: terminator [options] error no such option
i want the netstat and nmap commands to appear and stay in their own terminal windows, how can i do this?

推荐答案

时,通过在命令中运行一个独立的程序生成的终端窗口。试试这些变化之一:

The terminal window is generated by a separate program from the command running inside. Try one of these variations:

xterm -e airomon-start wlan0 "$channel","$channel" &

gnome-terminal -x airomon-start wlan0 "$channel","$channel" &

konsole -e airomon-start wlan0 "$channel","$channel" &

选择调用你喜欢的终端程序的命令。你必须为做到这一点的要在自己的窗口中运行的每个的命令。此外,您还需要使用一个单独的&安培; 在每个这样的命令行的末尾 - 不是双&放大器;&安培; - 那些做完全不同的事情。和你的脚本的最后一行应该只是

Pick the command that invokes the terminal program you like. You'll have to do this for every command that you want run in its own window. Also, you need to use a single & at the end of each such command line -- not a double && -- those do totally different things. And the last line of your script should be just

wait

这使得它不会退出了从下所有终端,可能导致他们都死了。

that makes it not exit out from under all the terminals, possibly causing them all to die.

强制性切线的shell脚本鸡蛋里挑骨头:始终把shell变量双引号内使用,除非你的知道一个事实的,你需要的单词拆分对特定用途发生

Obligatory tangential shell-scripting nitpick: ALWAYS put shell variable uses inside double quotes, unless you know for a fact that you need word-splitting to happen on a particular use.

这篇关于我如何开始bash脚本在新终端的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆