|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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 | Display Modes |
|
#1
|
|||
|
|||
|
what does if[$? -ne 0] mean in unix
Hi,
what does this mean in unix if [$? -ne 0] I understand ne is not equal to zero but how abt $? Also, what does exit 1 or exit 0 mean. Last edited by shree; 06-15-2006 at 12:16 PM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
if [$? -ne 0]
$? is the return code form a previous command or function
in unix, 0 is the standard return code for a successful completion if [$? -ne 0] The whole line means 'if the previous return code was not equal to 0 ' .... It will then be followed by then statement # do something (optional) else (optional) statement # do something else fi # closure of the 'if' conditional Steve |
| The Following User Says Thank You to steweston For This Useful Post: | ||
sriniv666 (05-24-2011) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks Steve.
but another question. I have a FTP process happening and the file from remote m/c is FTPed to local m/c's file called result file, now how can I check if the FTP process was fine and if a result file was created. |
|
#4
|
||||
|
||||
|
This is not a technical forum. Mods please move this thread to the appropriate forum.
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
thanks for the information.....but can u tell me what is the previous return code............
is the command or code above the if statement ? im very new to shell scripting..........any help ? and also can u tell me what does this means if [ $# -ne 3 ]; |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Quote:
If the number of arguments is not equal to 3 ... do something. You should begin by reading An Introduction To Shell Programming ... and when you finish proceed to: http://www.unix.com/answers-frequent...tutorials.html Last edited by danmero; 07-21-2008 at 01:04 AM.. Reason: add link to tutorials |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
Hello Shree,
To verify whether data copying is happened properly, you can use "md5sum" check. get the original file md5sum and again get it after copying it to local machine. Compare them. If same then file has been copied properly else issue while copying file. And to check if result file has been created use, if [ -e "filename" ] then echo "File exist" else echo "File does not exist" fi Please let me know if u need more help. - nilesh Last edited by ynilesh; 07-21-2008 at 12:49 AM.. |
| Sponsored Links | ||
|
![]() |
| Tags |
| linux, solaris |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How does unix system administration, unix programming, unix network programming differ? | thulasidharan2k | UNIX for Dummies Questions & Answers | 0 | 06-09-2011 09:40 AM |
| Running UNIX commands remotely in Windows box from Unix box – avoid entering password | D.kalpana | UNIX for Dummies Questions & Answers | 1 | 04-20-2007 05:24 AM |
| Unix History Question: Why are filenames/dirnames case sentsitive in Unix? | deckard | UNIX for Dummies Questions & Answers | 3 | 03-26-2005 12:59 PM |
|
|