Nmap Development mailing list archives
Re: Ndiff included in Windows zip distribution
From: David Fifield <david () bamsoftware com>
Date: Wed, 4 Feb 2009 18:49:44 -0700
On Thu, Feb 05, 2009 at 02:14:34AM +0100, David Fifield wrote:
On Wed, Feb 04, 2009 at 06:39:14PM -0600, DePriest, Jason R. wrote:would using "%COMSPEC%" /c "%PYTHON%" "%PROG%" %* maintain the exit state?You know what, it turns out that the way I wrote the script, the ndiff exit code is propagated outside the batch file, because the call to python.exe is the very last statement. I had it written in a different way before where it didn't work and didn't test it again when I rewrote it.
Wait, I'm confusing myself again. I wrote this after I had made Tom Sellers's changes from http://seclists.org/nmap-dev/2009/q1/0299.html, which did make the call to python.exe the last thing in the file. But as I wrote it it's not that way. However I found a trick from http://code-bear.com/bearlog/2007/06/01/getting-the-exit-code-from-a-batch-file-that-is-run-from-a-python-program/. -"%PYTHON%" "%PROG%" %* - -endlocal +endlocal & "%PYTHON%" "%PROG%" %* endlocal would normally destroy the values of PYTHON and PROG, but when the command is chained with &, they keep their values until the end of the setlocal line. This does the trick.
And in fact the "exit /b 1" syntax used when python.exe can't be found works too, at least in the Windows shell. If I break the python.exe search, run ndiff.bat, and "echo %ERRORLEVEL%", I get 1 as expected. What doesn't work is "echo $?" from a Cygwin Bash shell when the python.exe search fails--even though $? works when when ndiff.py is run successfully. I only tested it in Bash before so I didn't notice that it worked in cmd.exe. So apart from that very minor Cygwin issue, I think this is solved.
All this is true now. The exit code propagates in every case except when running in Cygwin Bash and python.exe or ndiff.py can't be found. David Fifield _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Ndiff included in Windows zip distribution David Fifield (Feb 04)
- Re: Ndiff included in Windows zip distribution Fyodor (Feb 04)
- Re: Ndiff included in Windows zip distribution Tom Sellers (Feb 04)
- Re: Ndiff included in Windows zip distribution David Fifield (Feb 04)
- Re: Ndiff included in Windows zip distribution DePriest, Jason R. (Feb 04)
- Re: Ndiff included in Windows zip distribution David Fifield (Feb 04)
- Re: Ndiff included in Windows zip distribution David Fifield (Feb 04)
- RE: Ndiff included in Windows zip distribution Aaron Leininger (Feb 04)
- Re: Ndiff included in Windows zip distribution Tom Sellers (Feb 04)
- Re: Ndiff included in Windows zip distribution Fyodor (Feb 04)