i have the following case :-
i write bash file bbb
in windows 2003 and but a return value = 3 by exit /b 3
then i execute this bash file from unix by this command :- ssh -l admin host 'cmd /c start c:\bbb'
but when i print the return value i get ( 0 ) not ( 3 ) i print this value by `echo $? ' now how i can get a return value "exit code" from windows bash ?
views:
54answers:
2
+2
A:
Your return code is being masked by start
, you should not be using it in this case.
Hasturkun
2010-10-03 09:46:17
if i can't use `start` what i should use ?
Osama Ahmad
2010-10-03 09:52:17
if `bbb` is indeed a bash script, you should run it using `bash`, not `cmd`. eg, `ssh -l admin host 'bash bbb'`, or without bash if your ssh runs bash by default.
Hasturkun
2010-10-03 11:10:58
i try with bash and without anything the result is :-` bash: c:bbb.bat: No such file or directory` .... and remember i want to execute batch file in windows
Osama Ahmad
2010-10-03 11:24:26
is `bbb` a `bash` script or a `cmd` batch file? I'm sort of confused here. anyway, if it _is_ a batch file the previously suggested `cmd /c c:\\bbb.bat` will work. remember to double your backslashes as they act as escape characters and will be expanded by the remote side.
Hasturkun
2010-10-03 12:01:06
thaaaaaaaaaaaaaaank you very much :)
Osama Ahmad
2010-10-03 12:09:54
A:
your $?
is the return code of ssh command. I don't have a windows machine to try, you could echo the %errorlevel%
after your cmd
command
ghostdog74
2010-10-03 10:58:54
Osama Ahmad
2010-10-03 11:15:56