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
! operator in variable mmunir Shell Programming and Scripting 1 05-30-2008 12:29 AM
Help need: new line operator : satyam_sat Shell Programming and Scripting 3 04-07-2008 06:31 AM
Or operator with if babom HP-UX 1 10-03-2007 12:56 PM
ternary operator naan High Level Programming 1 04-12-2007 12:58 AM
Operator question TheCrunge UNIX for Dummies Questions & Answers 5 03-01-2005 12:27 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-03-2005
Registered User
 

Join Date: Aug 2005
Posts: 9
And operator

I am trying to check two variables and if both are blank I want to set a flag:

Code:
the_f3_pid=`rsh $target ps -ef | grep "f3.eab" | awk '{print $2}'`
the_f7_pid=`rsh $target ps -ef | grep "f7.eab" | awk '{print $2}'`

if [ "$the_f3_pid" = "" && "$the_f7_pid = "" ] ; then
  y=1
fi
I get an error:

./script_name[18]: test: 0403-021 ] character is missing.

the_f3_pid and the_f7_pid are both blank since the software is not running on the machine I am checking.

Any ideas ?

Thanks,
RC
Reply With Quote
Forum Sponsor
  #2  
Old 08-03-2005
Registered User
 

Join Date: Aug 2005
Posts: 9
Is appears if I use and instead of && that it works ok.
Reply With Quote
  #3  
Old 08-03-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,609
Change
"$the_f7_pid
to
"$the_f7_pid"

Also change
&&
to
-a
Reply With Quote
  #4  
Old 08-03-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,003
change '&&' to '-a'
Reply With Quote
  #5  
Old 08-03-2005
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
You can also do the work without using the and operator :

Code:
if [ "$the_f3_pid$the_f7_pid" = "" ] ; then
  y=1
fi
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:29 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