Unknown problem-beginner


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unknown problem-beginner
# 1  
Old 02-20-2010
Question Unknown problem-beginner

Hi, I have a problem running my script.Here it is:
Code:
num1="1"
num2="2"
num3="3"
num4="4"
num5="5"
num6="6"
num7="7"
echo
echo "Type what you wanna do..."
echo "1= Start interface   2= Stop interface   3= See your mac"
echo "4= Change your mac   5= Hack WEP......   6= Hack WPA...."
echo "IF YOU RUN FIRST TIME --> 7= Say which is your interface"
read number
if [ "$number" == "$num1" ] then

	int=`cat /home/alex/Documents/hakforothers/${int}`
airmon-ng start $int
elif [ "$number" == "$num2" ] then
 
	int=`cat /home/alex/Documents/hakforothers/${int}`
airmon-ng stop $int
elif [ "$number" == "$num3" ] then

	int=`cat /home/alex/Documents/hakforothers/${int}`
macchanger -s $int
elif [ "$number" == "$num4" ] then
 
	int=`cat /home/alex/Documents/hakforothers/${int}`
macchanger -m 00:11:22:33:44:55 $int
elif [ "$number" == "$num5" ] then
exit
elif [ "$number" == "$num6" ] then
exit
elif [ "$number" == "$num7" ] then
echo $int > /home/alex/Documents/hakforothers/${int}
						fi
					fi
				fi
			fi
		fi
	fi
fi

Well, what it actually does? Hmm... It supposed to do the following:
When it was first time run, the user would push 7 in order to give his interface (in the program $int). This interface would be written in a file in /home/alex/Documents/hakforothers/.Then, when the user typed an other number, the other programs should call this file and use it.(the 5 and 6 are unavailable for now)
Unfortunately, it says
Code:
Type what you wanna do...
1= Start interface   2= Stop interface   3= See your mac
4= Change your mac   5= Hack WEP......   6= Hack WPA....
IF YOU RUN FIRST TIME --> 7= Say which is your interface
7
./hakfile: line 18: syntax error near unexpected token `elif'
./hakfile: line 18: `elif [ "$number" == "$num2" ] then'


Last edited by hakermania; 02-20-2010 at 11:29 AM.. Reason: to add something
# 2  
Old 02-20-2010
Quote:
Originally Posted by hakermania
Code:
read number
if [ "$number" == "$num1" ]; then

Missing semi-colon.

Quote:
Originally Posted by hakermania
When it was first time run, the user would push 7 in order to give his interface (in the program $int).
And where you declare $int variable ?

On my opinion you should opt for a case/esac statement like:

Code:
#!/bin/sh
while :;do echo "
Type what you wanna do...
1= Start interface   2= Stop interface   3= See your mac
4= Change your mac   5= Hack WEP......   6= Hack WPA....
IF YOU RUN FIRST TIME --> 7= Say which is your interface"
read number
        case $number in
                1)
                        int=`cat /home/alex/Documents/hakforothers/${int}`
                        airmon-ng start $int;;
                2)
                        int=`cat /home/alex/Documents/hakforothers/${int}`
                        airmon-ng stop $int;;
                3)
                        int=`cat /home/alex/Documents/hakforothers/${int}`
                        macchanger -s $int;;
                4)
                        int=`cat /home/alex/Documents/hakforothers/${int}`
                        macchanger -m 00:11:22:33:44:55 $int;;
                5|6)
                        exit;;
                7)
                        echo $int > /home/alex/Documents/hakforothers/${int};;

                *)
                        echo "[$number] wrong option, try again !";;
        esac
done

# 3  
Old 02-21-2010
Oh! Got it!
thx I'll try it in a bit!

---------- Post updated at 02:31 AM ---------- Previous update was at 02:19 AM ----------

OK, I managed to do it!
Thx!
# 4  
Old 02-21-2010
For basic string comparison we should replace:
Quote:
if [ "$number" == "$num1" ] then
with

Quote:
if [ "$number" = "$num1" ]
then
# Do something
else
# Do something else
fi
There is no reason to use "==" in this context.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Help me please i am beginner

i have windows 8 host on Dell Laptop vmware 9 redhat 7.2 iso downloaded through redhat official site after installation on vm it only boots into text dont show graphics Please guide:( (1 Reply)
Discussion started by: hananabbas
1 Replies

2. Shell Programming and Scripting

Unknown (probably) simple problem with my code

I'm relatively new to both UNIX and Linux and slightly less new at programming. But I can't figure out why this won't run properly. It's meant to calculate the GCD of two numbers (simple enough, you'd think). And I designed it myself and it looks good to me and my instructor won't respond. If... (1 Reply)
Discussion started by: Sevchenko
1 Replies

3. Programming

C++ Beginner Problem With Optget

Hi. I am new to C++. But I am trying to write a basic program that uses the command line. But... $ ./myscript -s 1 -e 8 -c billy -v 1 -o test I get output like this... Starting Length = 1 Ending Length = 8 Name = (null) Output File = (null) Verbose = 1 How come 'Name' and 'Output... (2 Replies)
Discussion started by: cbreiny
2 Replies

4. UNIX for Dummies Questions & Answers

Beginner - What Should I Do First?

Hi people.... I have just started to learn unix.I want to know which version of Unix to install plus how to install it.I need to practise and make myself aware of how unix works.My thread is from an educational point of view.Also please feel free to give your suggestions as I am... (3 Replies)
Discussion started by: amit.kanade1983
3 Replies

5. Shell Programming and Scripting

Unknown Problem. I really want your help to solve this!

Take a look on this code: #!/bin/sh currentpath=`pwd` if ; then #Normal user if ; then "$currentpath"/.cleaner else ./runit fi else #Root user if ; then rm -r /some fi mkdir /some cd /home/ echo "`ls --group-directories-first -1`" > /some/allusers cat /some/allusers | sed 's/... (17 Replies)
Discussion started by: hakermania
17 Replies

6. UNIX for Dummies Questions & Answers

Beginner Help

hi guys, i have a DEl xps laptop cor 2 duo 2.2 i have vista installed on it i want to install a dual Boot UNIX on it.. can some one guide me ...cause i m tottaly new to UNIX i want to install unix on that laptop along with Vista.... thx any help would be deeply appreciated (sorry if i... (5 Replies)
Discussion started by: Farhan082
5 Replies

7. Solaris

PING - Unknown host 127.0.0.1, Unknown host localhost - Solaris 10

Hello, I have a problem - I created a chrooted jail for one user. When I'm logged in as root, everything work fine, but when I'm logged in as a chrooted user - I have many problems: 1. When I execute the command ping, I get weird results: bash-3.00$ usr/sbin/ping localhost ... (4 Replies)
Discussion started by: Przemek
4 Replies

8. Shell Programming and Scripting

Beginner export problem

Me dumb. Can't get this to work... #!/bin/sh export JAVA_HOME_BAK=${JAVA_HOME} or #!/bin/sh export JAVA_HOME_BAK=/usr/java or #!/bin/sh export JAVA_HOME_BAK=$JAVA_HOME or #!/bin/sh export JAVA_HOME_BAK $JAVA_HOME etc.... none work. Either i get: "JAVA_HOME_BAK=/usr/java: is not... (1 Reply)
Discussion started by: xplodersuv
1 Replies

9. Shell Programming and Scripting

Please help. I am a beginner.

Alrigt, I need to write a shell script where it counts the number of folders and files and dispays "My home directory has 'x' files and 'y' directories." So, I was thinking of doing this. set x = `ls | wc` so, if I have 8 files and folders in my home directory, x is not 8. now, I was... (1 Reply)
Discussion started by: Lykathea Aflame
1 Replies

10. Programming

A beginner's problem

Hi, I'm a beginner to study linux program, I know use gcc can link one *.c file to a exe file, but how to link different source files(*.c) to a exe at once. AnyBody know and tell me, thanks. (2 Replies)
Discussion started by: kira_freedom
2 Replies
Login or Register to Ask a Question