简体   繁体   中英

Vagrant how to get exit code from Windows command over SSH?

I am using a Vagrant VM with Windows 7 for an automated build process.

If I SSH directly into Windows, I can see that %ERRORLEVEL% is being set:

$ vagrant ssh
> false
> echo %ERRORLEVEL%
1

However, if I send an SSH command to Windows directly, Vagrant does not use the exit code:

$ vagrant ssh -- cmd.exe /C 'false'
$ echo $?
0

Is there a way to pass the Windows %ERRORLEVEL% variable from the command executed via Vagrant SSH back to my host shell? I'm hoping that the solution doesn't involve redirecting the variable into a file.

what happens if you try:

vagrant ssh -- cmd.exe /C exit 1

just thinking cmd.exe /c is opening up a new command prompt and false is within that rather than returning anything outside like exit with value would!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM