Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like to get a return value 2 if command successful

Status
Not open for further replies.

RajShekar

Programmer
May 27, 2004
14
0
0
US
I want the below statement to return the value 2 if the ls command returns any files?

rc=$(rsh -l dmnida kdnidp02 "ls ${ZW_MONTHLY_PATH}${SD_FILE}.sum 2>/dev/null
 
untested....

Code:
rc=$(rsh -l dmnida kdnidp02 "if [ -f ${ZW_MONTHLY_PATH}${SD_FILE}.sum ]; then echo 2;fi;)

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I want to assign rc=2 if ls command lists any files.
 
Ah, OK you may try this:
rc=$(rsh -l dmnida kdnidp02 "ls ${ZW_MONTHLY_PATH}${SD_FILE}.sum 2>/dev/null")
[ -z "$rc" ] || rc=2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top