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
set Working day in ksh Rafael.Buria Shell Programming and Scripting 1 10-09-2007 01:42 AM
Not working Mandab Shell Programming and Scripting 7 05-11-2007 06:23 PM
FTP is not working. ronald_brayan Security 10 04-04-2007 05:23 AM
sed not working baanprog UNIX for Advanced & Expert Users 5 09-18-2006 05:11 AM
why is this not working? matt2kjones UNIX for Dummies Questions & Answers 2 07-09-2002 12:58 PM

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

Join Date: Apr 2007
Posts: 36
If Else not working

Status=`Executing Some Command`
if [ "${Status}" -ne "0" ]
then
echo "abc"
else
echo "..............."

command result is

Status code = -2 DSJE_BADSTATE

but it going to else statement.I beleive IF else is not working here.
actual result should be abc.
can any one help me to resolve this.
Reply With Quote
Forum Sponsor
  #2  
Old 05-01-2008
sad_angle's Avatar
Registered User
 

Join Date: Jun 2001
Location: Madison, WI
Posts: 73
fi is required

try to add fi at the end. It worked for me

Ksh basics

Good luck
Reply With Quote
  #3  
Old 05-02-2008
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
Use:
Code:
if [ "${Status}" != "0" ]
Reply With Quote
  #4  
Old 05-02-2008
Registered User
 

Join Date: Apr 2007
Posts: 36
i have checked with fi
if fi it should have been give syntax error.

Note the status code : either 0
or -2 DJERROR

how can we handle these status codes.
Reply With Quote
  #5  
Old 05-02-2008
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
What about this one?

if (( ${status} != 0 ))
Reply With Quote
  #6  
Old 05-02-2008
Registered User
 

Join Date: Apr 2007
Posts: 36
I have tried with above one.

below message

Status code = -2 DSJE_BADSTATE
DS_Operations.sh[187]: != 0 : 0403-058 Assignment requires an lvalue.
Reply With Quote
  #7  
Old 05-02-2008
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
What values could ${status} get?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




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