![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accessing variables of one shell script in another shell script | rsendhilmani | Shell Programming and Scripting | 2 | 03-17-2009 01:17 AM |
| Ask Linux.com: Lost passwords, lost files, and terminal tricks redux | iBot | UNIX and Linux RSS News | 0 | 08-31-2008 10:10 AM |
| invoking a shell script inside cgi shell script | smriti_shridhar | Shell Programming and Scripting | 2 | 07-09-2008 02:50 AM |
| How to Run a shell script from Perl script in Parent shell? | hifake | Shell Programming and Scripting | 16 | 08-28-2007 09:42 PM |
| Lost Data Lost Admin | murphsr | Filesystems, Disks and Memory | 3 | 09-07-2005 03:35 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
New to shell script and lost....
I am really stuck on something I am sure you all will find simple.
I am VERY new to shell scripting and I am trying to figure out how to do a or statement below. So if it = 11 or 31 then... if [ $? != '11' ]; then Please keep in mind I do not know much on shell scripting and thank you in advance as I learn. Last edited by LRoberts; 10-16-2008 at 12:47 PM.. |
|
||||
|
hi ,
please note the syntax changes per shell , you have not mentioned the shell i will tell how to do it in ksh if [ "$x" = "11" ];then if [ "$x" = "31" ] ;then <<do something >>> -- atleast 1 statement else << if you want some-thing in else -case >> fi fi -- if u want any else case then u can put a else as a layer |
|
||||
|
I tried it this way thinking it would work....
if [ $? != '11' ] || [ $? != '31' ]; then But that did not seem to work. I need to check if the $? is either a 11 or a 31. If its not either one then do action. I am really lost on the format... |
|
||||
|
$? is the return status of a process or command
Code:
#/bin/ksh some_command goes here it=$? # one way if [[ $it -eq 31 || $it -eq 11 ]] ; then # do something fi # or this way, preserving the result of the test for further use test_result=$(( it == 11 | it == 31 )) # C boolean operators: ==, !=, >, >=, etc. # at this point test_result is either 0 (not true) or 1 (true) |
|
||||
|
Ok I got this now....
Value=$? if [[ $Value != '11' || $Value != '31' ]]; then echo $Value echo "Code 11: CheckAutoUp is reporting Autosys as down. Sending event to Omnibus..." $EIF_HOME/bin/solaris2/postemsg -f$EIF_HOME/eif.conf -rFATAL -m"AutosysCheckAutoUp has failed." OnCallGroup="INFR_APPS" ISOC_Instruc tions="Please contact INFR_APPS." TEC_Class=68403 AUTOSYS_CHKAUTOUP Autosys I know the value does = 11. For some reason the above code is doing the then statement even though the value does = 11. What am I doing wrong? |
![]() |
| Bookmarks |
| Tags |
| autosys |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|