![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what these statements means | namishtiwari | UNIX for Dummies Questions & Answers | 1 | 01-16-2008 11:20 PM |
| Automate SQL statements | panchpan | SUN Solaris | 3 | 01-02-2008 11:32 PM |
| Please help on IF statements. | filthymonk | Shell Programming and Scripting | 4 | 07-18-2007 02:59 AM |
| or statements? | Blip | Shell Programming and Scripting | 1 | 01-19-2004 01:08 PM |
| if statements | lilas | UNIX for Dummies Questions & Answers | 2 | 03-22-2001 08:49 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Else in If Statements
Sorry to be a pain, but how does the else work in the if statements?
Ive been making scripts with if statements but i cant get the else statements working. Can you help? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
can you show your script?
|
|
#3
|
|||
|
|||
|
well i haven't used the else in a script but for instance
if [ $choice = 1 ] then echo "cool its working" exit 1 else echo "not working try again" sh andy1 fi is this the correct way to use it |
|
#4
|
|||
|
|||
|
Quote:
Code:
if [ $choice -eq 1 ] |
|
#5
|
|||
|
|||
|
so the eq means if its not equal to 1 then its not correct? is that right?
|
|
#6
|
|||
|
|||
|
-eq means equal
-ne means not equal Code:
if [ $choice -eq 1 ] |
|
#7
|
|||
|
|||
|
Hi,
I tell you what i thinks we are getting confused, here is the full source code for the script im writing, run it and hit X to exit and i get an error. Type in a wrong number and it errors also clear echo echo echo echo echo "***********************************Welcome to INET Diagnostics Utility ***********************************************" echo "*************************************************************************************************** *******************" echo echo echo echo " 1) Ping Web Site" echo " 2) Telnet" echo " 3) Logit" echo " 4) Pico" echo " 5) Text Based Inetnet" echo " 6) Files Counter" echo " 7) File Lister" echo " 8) Backup Directories" echo " 9) Calculator" echo " 10) Calender" echo " 11) FTP Client" echo " 12) DNS Client" echo " X) Exit" echo echo echo echo echo " Choose your choice" echo "*************************************************************************************************** *******************" read choice if [ "$choice" -eq "1" ] then echo " To Escape A Ping Cycle Hold CTRL And Press C!" echo echo sleep 4 echo "Which Site Do You Wish To Ping? (Include full extension without the www) " read name echo echo echo ping -c 10 $name echo "Hit Enter To Return To The Main Menu!" echo "Paused............" read inet2 fi if [ "$choice" -eq "2" ] then echo " To Quit Telnet, Type Quit And Hit Enter!" echo echo sleep 4 echo " Which Server Do You Wish To Connect To?" read server echo echo " Which Port Do You Wish To Connect To?" read port echo echo echo telnet $server $port inet2 fi if [ "$choice" -eq "3" ] then echo " Now Transfering To Logit!" sleep 4 logit inet2 fi if [ "$choice" -eq "4" ] then echo "Which File Do You Wish To Open? (If Not In Current Directory Use File Path Also!)" echo echo read picofile pico $picofile inet2 fi if [ "$choice" -eq "5" ] then echo " Connecting to Lynx Internet Browser" sleep 4 echo " To Quit Lynx Press Q At Any Time" sleep 3 lynx inet2 fi if [ "$choice" -eq "6" ] then echo " Enter Directory In Full" read dname echo echo echo echo "Total Files : " ls -l | grep -c ^- sleep 6 inet2 fi if [ "$choice" -eq "7" ] then echo "Loading Working Directory!" wd= "pwd" sleep 3 cd $wd echo "Loading File List Please Wait!" sleep 2 ls -R * echo "Hit Enter At Any Time To Return!" read inet2 fi if [ "$choice" -eq "8" ] then echo " Starting Backup Directories Now!" echo echo sleep 3 backup inet2 fi then echo "Type Quit And Hit Enter To Exit!" echo echo "Loading Calculator" echo echo sleep 3 bc inet2 fi if [ "$choice" -eq "10" ] then echo " Loading Calender" sleep 3 echo cal echo echo echo "Hit Enter To Return To Menu!" read inet2 fi if [ "$choice" -eq "11" ] then echo " Loading FTP Client" echo echo " To Exit Type Quit And Hit Enter" sleep 3 ftp inet2 fi if [ "$choice" -eq "12" ] then echo " Transfering To DNS" echo " Type Exit And Hit Enter To Exit" echo sleep 3 nslookup inet2 fi if [ "$choice" -eq "X" ] then echo "Goodbye" sleep 2 clear exit 1 fi |
|||
| Google The UNIX and Linux Forums |