How verify that the last instruction was success ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How verify that the last instruction was success ?
# 1  
Old 08-26-2009
How verify that the last instruction was success ?

Hi gusys.

I am developing a script that mount a filesystem ; I would like
verify that this instruction has finished OK !!!

I am tryin to use $? ; but I have doubt How use the if instruction with
the $? variable :

Code:
  mount machine:/dir /dir
   if  [ $? == "0" ]
   then
     action 1
   else
     action 2
   fi

Any better choise ?

Thank in Advance

AGAD

Last edited by DukeNuke2; 08-27-2009 at 02:55 AM.. Reason: added code tags
# 2  
Old 08-26-2009
There is nothing wrong with what you are doing

Code:
mount /IwantAPatekPhillipe /ButIcantAffordOne
 
mount:  you must specify the filesystem type
 
echo $?
32
 
 
mount /IwantAPatekPhillipe /ButIcantAffordOne
 
mount:  you must specify the filesystem type
 
if [ $? -eq 0 ]; then
  echo "Nice one!"
else
  echo "Get a better job."
fi

Get a better job.

Looks like you are mounting a remote directory (actually - you are!). Is that directory on the remote server exported?

Last edited by Scott; 08-26-2009 at 05:13 PM..
# 3  
Old 08-26-2009
I would prefer a numeric comparison. Others may differ.

Code:
if [ $? -eq 0 ]
then
            action 1
else
            action 2
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Illegal Instruction error

I keep getting a Illegal instruction error when running my MCP file below is the dump error message followed by truss log, dose anyone have any ideas? /opt/builds/bin/core: ELF 32-bit MSB core file SPARC Version 1, from 'mcp' *** Select Close or Exit from the window menu to close this window... (12 Replies)
Discussion started by: Wpgn
12 Replies

2. Shell Programming and Scripting

Cp r instruction

Pleas I want answer to this question? Pleas help me A system administrator suspects that there is an attack on his machine; he needs to make a backup of the files to check when they have been modified. For this purpose he uses the "cp -r" instruction to copy the root directory. What is the... (1 Reply)
Discussion started by: tamer11007
1 Replies

3. Shell Programming and Scripting

Open_ssh installation instruction ?

Hi , Currently the machine (solaris 10 ) is running with Sun_ssh. I would like to move to Open_ssh. I went through google. Each link shows different directions/ways to install openssh. I am not sure which one to follow . Installing OpenSSH Packages - SPARC and Intel x86/Solaris 9 and... (1 Reply)
Discussion started by: frintocf
1 Replies

4. Solaris

Openssh installation instruction ?

Hi , Currently the machine is running with Sun_ssh. I would like to move to Open_ssh. I went through google. Each link shows different directions/ways to install openssh. I am not sure which one to proceed with . Installing OpenSSH Packages - SPARC and Intel x86/Solaris 9 and 10 ... (0 Replies)
Discussion started by: frintocf
0 Replies

5. Programming

how to discard instruction from previous signal

hello everyone, I'm having a problem doing signal handling so I post this thread to see if I could get help. I want asynchronous signal handling, that means when I'm processing a signal (signal 1), if the same signal comes (signal 2) that signal (signal 2) shall be processed; and moreover,... (7 Replies)
Discussion started by: nvhoang
7 Replies

6. Solaris

what is that 1 in the instruction!~ (please help fast)

Hi all, make_lofs /.cdrom/<something>/<something> 1 what does this instruction mean? Note:both the "something" are obviously different . I would like to know what that 1 means, the rest of the instruction is clear!! Thanks (6 Replies)
Discussion started by: wrapster
6 Replies

7. UNIX for Advanced & Expert Users

Case Instruction

Hi, this is my script to make a choice between 4 : clear echo " choose a profile and enter a number" echo echo " 1- oraSTT " echo echo " 2- appSTT " echo... (3 Replies)
Discussion started by: big123456
3 Replies

8. Shell Programming and Scripting

Illegal instruction(coredump)

Hi I am trying to execute a simple grep command looking for records in a filename that start with 01 (grep ^01 filename) and am getting the error Illegal instruction(coredump). Has anyone any idea why this happens? Is it due to the file being corrupted? Thanks (1 Reply)
Discussion started by: colinmas
1 Replies

9. Linux

i am new yuser of linux give instruction?

:confused: Can i installed winamp on RHAT 9? if yes the how? how can i play vidio cd/dvd on it ? (2 Replies)
Discussion started by: pagal_no_1123
2 Replies

10. UNIX for Dummies Questions & Answers

2489 Illegal instruction

Hello I am trying to execute a back up from one queue manager from one script saveqmgr.sh but I am getting 2489 Illegal instruction on line 16 $ sh +x ./saveqmgr.sh S1SEAGULL QueueManager=S1SEAGULL Retention= S1SEAGULL.MQS.14Jan2005 not found ./saveqmgr.sh: 2836 Illegal... (1 Reply)
Discussion started by: ana
1 Replies
Login or Register to Ask a Question