views:

54

answers:

2

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 ?

+2  A: 

Your return code is being masked by start, you should not be using it in this case.

Hasturkun
if i can't use `start` what i should use ?
Osama Ahmad
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
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
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
thaaaaaaaaaaaaaaank you very much :)
Osama Ahmad
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
Osama Ahmad
`%errorlevel%`.
ghostdog74