LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 08-31-2008, 08:43 PM   #1
budhax
LQ Newbie
 
Registered: Aug 2008
Location: Switzerland - GVA
Distribution: BT3
Posts: 8

Rep: Reputation: 0
Question Strange echo output and "case" error ?


Hello,
1. Why some echo output lines (04,05,07,11,14) are bad built?
I think it concerns only lines where the echo string continues after a $variable, like:
echo "blablabla $var blabla"
echo "blablabla $var1 $var2"
echo "blablabla $var1 bla $var2"


2. I cannot find/understand the error in line 31. What's wrong?

My script:

Code:
#------------------------------------------------------------------------------------ Initialisation
DFN=file
CN1=eth1
RTAP0=rtap0
MESSID=IPW22
FIP_100=192.168.1.100
FIP_101=192.168.1.101
MAC=50:41:32:23:14:05
#----------------------------------------------------------------------------------------- Functions
menu {
	echo 
	echo "-- CHECK - CONFiG"
	com01="airmon-ng";echo  "01. $com01"
	com02="iwconfig $CN1";echo  "02. $com02"
	com03="iwlist";echo  "03. $com03"
	com04="iwlist $CN1 scan";echo  "04. $com04"
	com05="iwconfig $CN1 mode monitor";echo  "05. $com05"
	com06="airmon-ng start $CN1";echo  "06. $com06"
	com07="ifconfig $CN1 up hw ether $MAC";echo  "07. $com07"
	echo "-- TEST INJECTION"
	com08="Set CH: [$CH]";echo  "08. $com08"
	com09="Set ESSID: [$ESSID]";echo  "09. $com09"
	com10="Set BSSID: [$BSSID]";echo  "10. $com10"
	com11="airodump-ng --write $DFN $CN1";echo  "11. $com11"
	com12="aireplay-ng --test -e $ESSID -a $BSSID $CN1";echo  "12. $com12"
	echo "-- PLAY AND CRACK"
	com13="aireplay-ng -2 -r arp-request $CN1";echo  "13. $com13"
	com14="aircrack-ng -z -0 $DFN*.cap";echo  "14. $com14"
	echo "Choix?";read com
	case $com in
		#-- CHECK - CONFiG
		01) $com01;;
		02) $com02;;
		03) $com03;;
		04) $com04;;
		05) $com05;;
		06) $com06;;
		07) $com07;;
		#-- TEST INJECTION
		08) echo CH ?;read CH;;
		09) echo ESSID ?;read ESSID;;
		10) echo BSSID ?;read BSSID;;
		11) $com11;;
		12) $com12;;
		#-- PLAY AND CRACK
		13) $com13;;
		14) $com14;;
		*) echo "BYE BYE ...";exit;;
	esac
}
#---------------------------------------------------------------------------------------------- BODY
while true;do menu
done
exit
#---------------------------------------------------------------------------------------------------
provide this output:
Code:
bt ac # CWEP1.sh
./CWEP1.sh: line 10: menu: command not found

-- ********************* Standard WEP-CRACK
-- CHECK - CONFiG
01. airmon-ng
02. iwconfig eth1
03. iwlist
 scanwlist eth1
 mode monitoreth1
06. airmon-ng start eth1
 up hw ether 50:41:32:23:14:05
-- TEST INJECTION
08. Set CH: []
09. Set ESSID: []
10. Set BSSID: []
 eth1irodump-ng --write file
12. aireplay-ng --test -e  -a  eth1
-- PLAY AND CRACK
13. aireplay-ng -2 -r arp-request eth1
*.capircrack-ng -z -0 file
Choix?
01
': not a valid identifier: `com
'/CWEP1.sh: line 31: syntax error near unexpected token `in
'/CWEP1.sh: line 31: `  case $com in

Last edited by budhax; 08-31-2008 at 09:07 PM.
 
Old 08-31-2008, 08:52 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,294

Rep: Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358
I don't think that's allowed by the LQ rules (cracking). Reported.
 
Old 08-31-2008, 09:00 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
When defining a function, you should put a pair of brackets after the function name and before the { i.e.
Code:
menu () {
   ...
}
I think that's the source of your problem.

I would like to add some some general points of advice:

When take the value of variables, like in the case statement, it's usually a good idea to quote the string.
Code:
case "$com" in 
...
While it's syntactically ok to have multiple commands things on one line separated by semicolons, it makes your script hard to read. It's more conventional to put one command per line, although some people (myself included) often write "if [ ... ]; then" and "while [ ... ]; do". That you don't put spaces after one command is also nagging at me, although I think it's legal.
 
Old 08-31-2008, 09:38 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Closed for the time being - discussing the issue of supporting wrappers
around cracking tools with the other mods.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cifs "mount error 5 = Input/output error" but smbfs works! humbletech99 Linux - Networking 26 03-13-2017 08:45 AM
output the path for files whose names include string "string" (case insensitive) sean_zhang Linux - Newbie 1 03-04-2008 11:59 PM
What is wrong in the statement: $line || echo "error" && break; nadavvin Linux - General 1 08-05-2006 05:25 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 02:14 PM
qmail: strange output of "file" command slowleak Linux - Security 1 08-10-2001 10:40 PM


All times are GMT -5. The time now is 08:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration