LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-28-2002, 05:36 PM   #1
verbal
Member
 
Registered: Jul 2002
Location: New York
Distribution: Red Hat 7.2, SuSE 7.3
Posts: 60

Rep: Reputation: 15
bash Shell Programming Curiosity...


Hey all...

I recently decided to dip my big toe into shell scripting; never really having a need for until recently. I am working on a simple little script right now which seems to work fine, only it generates an error before continueing on to execute the whole script flawlessly:

:/home/sallow>testsrv -c -u sallow
/usr/local/bin/testsrv: [: !=: unary operator expected

The appearance of the error is the only indication of an issue, as I stated above, the script performs without any issues at all.

The only area in the code in which I use a 'not equals' is here:

if [ $USERNAME != $USR ] ; then
...
fi

but I have tested this block of code to make sure that it is doing its job and there are no performance issues.. ??

All in all, since the code works, I'm not overly concerned, but at the same time, I have such a hard time leaving anything alone til its perfect

Could anyone shed any light on the meaning of this error?

Thanks in advance,

Verbal
 
Old 08-28-2002, 05:55 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
presumably an unintialised variable. make sure each variable has a dummy value (e.g. -1 or -9999 etc..) before you could conditionally assign something to the value. also try debugging by echoing out each variables value before such operations
 
Old 08-28-2002, 06:14 PM   #3
verbal
Member
 
Registered: Jul 2002
Location: New York
Distribution: Red Hat 7.2, SuSE 7.3
Posts: 60

Original Poster
Rep: Reputation: 15
thankyou...

I do have an array earlier in the script that has a possibility of some uninitialized values, I'll play around with this thought.

Thankyou for your input!

verbal
 
Old 09-03-2002, 10:42 AM   #4
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16
$USERNAME is not getting set properly.
 
  


Reply



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
Bash programming winterhunter Linux - Newbie 6 11-26-2007 07:14 AM
Question about bash shell programming walterbyrd Linux - General 1 11-01-2005 09:42 AM
bash shell programming vivek_kumbhar Linux - General 4 04-12-2004 07:13 AM
Shell Programming (BASH) nny0000 Programming 2 01-13-2004 05:53 PM
bash programming cpukiller Linux - Newbie 1 11-04-2003 06:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:33 PM.

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
Open Source Consulting | Domain Registration