The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error Message RDM00 UNIX for Dummies Questions & Answers 2 10-06-2006 07:43 PM
getting last error message tttttt UNIX for Dummies Questions & Answers 1 07-26-2006 03:07 PM
Error message ghuber UNIX for Advanced & Expert Users 1 11-14-2005 06:04 AM
error message vnc Castelior UNIX for Advanced & Expert Users 3 10-21-2004 05:50 AM
error message alisev UNIX for Dummies Questions & Answers 3 01-08-2002 05:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-29-2006
chapmana chapmana is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 23
Error Message

I keep getting an error message in a script im writing, this line is allways pointed out.

if [ $choice =1 ]

and this is the message i keep getting.

line 32: [: 8: unary operator expected

Whats wrong with it?

Please Help.
  #2 (permalink)  
Old 11-29-2006
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,993
try if [ $choice = "1" ]
______________^
_____________blank!
  #3 (permalink)  
Old 11-29-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
If you surround $choice within double-quotes, then null values are retained.

You could do this.


Code:
if [ "$choice" = 1 ]

Or you could do


Code:
if [ x$choice = x1 ]

  #4 (permalink)  
Old 11-29-2006
chapmana chapmana is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 23
Cheers

That worked but now im getting an error when an incorrect character is entered. Any ideas?
  #5 (permalink)  
Old 11-29-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Quote:
Originally Posted by chapmana
That worked but now im getting an error when an incorrect character is entered. Any ideas?
No ideas unless you show us what you tried. And what was the incorrect character ?

Looking at the variable name, I guess you are trying to read in user's choice from the command line. Show us the script.
  #6 (permalink)  
Old 11-29-2006
chapmana chapmana is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 23
This is the code, but when i enter an if statement saying if greater that 12 the echo an error message but when im typing X in to exit its saying its an incorrect character entered but i thought that it wouldn't affect alpha characters?



Code:
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" = "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
inet

   fi

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0