Hi all,
I have a situation to read exit value of a command (not exit code) and process further.
bash-4.2$ returnvalue=`ssh DOMAIN\\\\user1@10.7.7.68 'cmd /c "del C:\Users\user1\db_test.bak"'`
Could Not Find C:\Users\user1\db_test.bak
bash-4.2$ echo $?
0
bash-4.2$ echo $returnvalue
bash-4.2$
I intentionally made "db_test.bak" not available because i want the return value to be captured.
The expectation is the return value " Could Not Find C:\Users\user1\db_test.bak
"to be assigned in a variable.
Appreciate your help
Thanks
Bala
Hello baluchen,
Could you please try following and let me know if this helps you.
ssh user_name@host "commands" 2>error_output
Now above will capture the errors if any will come from commands, if you want to see them then you could run following command.
cat error_output >&2
Let me know how it goes it then.
Thanks,
R. Singh
1 Like
RudiC
3
Try
returnvalue=`ssh DOMAIN\\\\user1@10.7.7.68 'cmd /c "del C:\Users\user1\db_test.bak"' 2>&1`
although I'm not too sure how MS handles error msgs to stderr nor how it assigns exit codes.
Thank you Singh. It worked as expected.
Thank you
Bala