And operator | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

And operator

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-03-2005
rcarnesiii rcarnesiii is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 3 March 2014, 2:09 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 08-03-2005
rcarnesiii rcarnesiii is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 3 March 2014, 2:09 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Is appears if I use and instead of && that it works ok.
Sponsored Links
    #3  
Old 08-03-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 20 November 2014, 5:33 PM EST
Location: Ashburn, Virginia
Posts: 9,930
Thanks: 64
Thanked 438 Times in 261 Posts
Change
"$the_f7_pid
to
"$the_f7_pid"

Also change
&&
to
-a
    #4  
Old 08-03-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 21 November 2014, 12:13 PM EST
Location: Foxborough, MA
Posts: 7,668
Thanks: 153
Thanked 586 Times in 551 Posts
change '&&' to '-a'
Sponsored Links
    #5  
Old 08-04-2005
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
 
Join Date: Apr 2004
Last Activity: 27 October 2014, 1:32 PM EDT
Location: Bordeaux, France
Posts: 1,711
Thanks: 2
Thanked 61 Times in 57 Posts
You can also do the work without using the and operator :


Code:
if [ "$the_f3_pid$the_f7_pid" = "" ] ; then
  y=1
fi

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Awk with or and not operator infernalhell Shell Programming and Scripting 1 06-12-2011 12:26 PM
sed or operator shyamxtasy Shell Programming and Scripting 5 10-16-2010 09:55 PM
+= operator astrolux444 UNIX for Dummies Questions & Answers 3 09-06-2010 12:05 PM
su with << operator arunkumar_mca UNIX for Dummies Questions & Answers 3 12-29-2009 11:29 PM
SED * operator sinpeak Shell Programming and Scripting 7 12-24-2008 10:07 AM



All times are GMT -4. The time now is 01:42 PM.