Linux – Get the return value of bat file in Windows in Unix

bashcommand-line-interfacelinuxunixwindows

I have the following case :-
I write a batch file bbb in Windows 2003 and put a return value = 3 by exit /b 3 then I execute this batch file from Unix by this command :- ssh -l admin host 'cmd /c start bbb' but when I print the return value I get ( 0 ) not ( 3 ). I print this value by echo $?. Now how can I get a return value "exit code" from Windows batch?

Best Answer

You can't use the exact code for bash and batch at the same time.

My guess would be the script follows a conditional, something like:

if WINDOWS
  exit /b 3
else
  exit 3

That's all pseudocode, I'm not sure what works for both systems.

Edit: Or you could go the easier route and write up two entirely different script files; job.bat and job.sh.