The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Writing a Utility Script raghav1982 Shell Programming and Scripting 10 04-21-2008 08:23 AM
Extracting select queries from script DILEEP410 Shell Programming and Scripting 3 04-10-2008 07:16 AM
Need help on SCRIPT(1M) utility amit4g UNIX for Dummies Questions & Answers 1 11-23-2006 12:49 AM
Want to use the output of Select statement in Unix script akhilgoel9 Windows & DOS: Issues & Discussions 4 05-27-2005 06:52 AM
Pipe SQL select statement results to script houtakker UNIX for Dummies Questions & Answers 6 10-31-2003 10:20 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-08-2008
Registered User
 

Join Date: Feb 2008
Posts: 41
script not working...select utility

#!/usr/bin/bash


name="$@"


myname=malay
#echo $myname

select firstname in $name;
do
if [$firstname!= $myname];then
echo $firstname
else
break
fi
done

invoking with:-
./script.sh one two three four five six seven eight nine malay
according to me the program control should come out when i will select the entry having my name[malay] but its not happening

can any one point out the error
Reply With Quote
Forum Sponsor
  #2  
Old 05-08-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 123
Hi,

Syntax error is there in the test condition. space must be there after the opening bracket and bfore the closing bracket, like this

if [ $firstname != $myname ];then

Thanks
Penchal
Reply With Quote
  #3  
Old 05-08-2008
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
put this line at the beginning of the script and debug it.

Code:
set -x
Reply With Quote
  #4  
Old 05-08-2008
Registered User
 

Join Date: Feb 2008
Posts: 41
ash-3.00$ ./script.sh one two three four malay
one two three four malay
malay
1) one
2) two
3) three
4) four
5) malay
#? 1
./script.sh: line 12: [: one!=: unary operator expected
bash-3.00$

this is the error coming
Reply With Quote
  #5  
Old 05-08-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 123
what are the changes that you made to the script
Reply With Quote
  #6  
Old 05-08-2008
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
make the changes as penchal suggested it will work fine for you..
There should be space as he suggested.

Thanks
Reply With Quote
  #7  
Old 05-08-2008
Registered User
 

Join Date: Feb 2008
Posts: 41
okay i got hold of the error

[ $firstname != $myname ]

...i was missing the spaces in between


thanks everyone who cared to help
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0