Script fails on return code greater than 1, but not on 1
Hello Martin,
A script returning with code 1 does is not processed the same way as a script returning a code greater than 1.
On linux, create two scripts:
script rc1:
#!/bin/sh
exit 1
script rc2:
#!/bin/sh
exit 2
then do chmod a+x rc*
and run remotely:
WinSCP /command "open sftp://<uid>:<psw>@<machine>" "option echo on"
"call echo hello" \
"call ./rc1" \
"call echo bye" \
"exit"
output:
...
hello
call ./rc1
call echo bye
bye
exit
and then run 2nd command:
WinSCP /command "open sftp://<uid>:<psw>@<machine>" "option echo on"
"call echo hello" \
"call ./rc2" \
"call echo bye" \
"exit"
output:
...
hello
call ./rc2
Command './rc2'
failed with return code 2 and error message
.
Why isn't return code 1 considered an error?
re. https://shapeshed.com/unix-exit-codes/
What exit code should I use?
...
1 - Catchall for general errors
2 - Misuse of shell builtins (according to Bash documentation)
126 - Command invoked cannot execute
...
Thanks,
Andre
A script returning with code 1 does is not processed the same way as a script returning a code greater than 1.
On linux, create two scripts:
script rc1:
#!/bin/sh
exit 1
script rc2:
#!/bin/sh
exit 2
then do chmod a+x rc*
and run remotely:
WinSCP /command "open sftp://<uid>:<psw>@<machine>" "option echo on"
"call echo hello" \
"call ./rc1" \
"call echo bye" \
"exit"
output:
...
hello
call ./rc1
call echo bye
bye
exit
and then run 2nd command:
WinSCP /command "open sftp://<uid>:<psw>@<machine>" "option echo on"
"call echo hello" \
"call ./rc2" \
"call echo bye" \
"exit"
output:
...
hello
call ./rc2
Command './rc2'
failed with return code 2 and error message
.
Why isn't return code 1 considered an error?
re. https://shapeshed.com/unix-exit-codes/
What exit code should I use?
...
1 - Catchall for general errors
2 - Misuse of shell builtins (according to Bash documentation)
126 - Command invoked cannot execute
...
Thanks,
Andre