|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Verifying if the shell command executed or not?
Hi,
I am working on a shell script that would verify if the mount command has executed or not. So , i have been doing this. mount /dev/cdrom /mnt/cdrom echo "$?" if [ "$?" = "0" ]; then echo " Mount succesful" else echo " Mount unsuccessful" fi I have the problem with the if stmt. It is displaying " Mount successful even when it hasn't" for example echo "$?" would give 32, instead of going else loop, it still enters the if block of the code. Can somebody help me with this.? --Sundeep |
| Sponsored Links |
|
|
|
|||
|
As a stylistic aside, that's really better written as
Code:
if mount /dev/cdrom /mnt/cdrom; then echo " Mount succesful" else echo " Mount unsuccessful ($?)" fi |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help Required: Command to find IP address and command executed of a user | loggedout | Security | 2 | 08-06-2008 09:12 PM |
| Any way to know wt command has been executed from last 2-3 days ? | manoja422002 | UNIX for Advanced & Expert Users | 3 | 03-26-2008 10:22 AM |
| perl - why is the shell script executed before the print command? | mjays | Shell Programming and Scripting | 3 | 09-21-2007 06:49 AM |
| problem executed shell command from PL/SQL | alodvg | Shell Programming and Scripting | 2 | 08-26-2006 03:58 AM |
| Verifying remote command status | ravikiran | HP-UX | 0 | 06-08-2006 11:36 AM |