And operator | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 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 Unix and Linux 08-03-2005
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 26 March 2015, 3:50 PM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 444 Times in 263 Posts
Change
"$the_f7_pid
to
"$the_f7_pid"

Also change
&&
to
-a
    #4  
Old Unix and Linux 08-03-2005
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is online now Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 27 March 2015, 11:20 AM EDT
Location: Foxborough, MA
Posts: 7,759
Thanks: 168
Thanked 631 Times in 589 Posts
change '&&' to '-a'
Sponsored Links
    #5  
Old Unix and Linux 08-04-2005
aigles's Unix or Linux Image
aigles aigles is offline Forum Advisor  
Registered User
 
Join Date: Apr 2004
Last Activity: 1 December 2014, 9:03 AM EST
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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 11:26 AM
sed or operator shyamxtasy Shell Programming and Scripting 5 10-16-2010 08:55 PM
+= operator astrolux444 UNIX for Dummies Questions & Answers 3 09-06-2010 11:05 AM
su with << operator arunkumar_mca UNIX for Dummies Questions & Answers 3 12-29-2009 10:29 PM
SED * operator sinpeak Shell Programming and Scripting 7 12-24-2008 09:07 AM



All times are GMT -4. The time now is 11:40 AM.