
Nmap Development mailing list archives
Re: Ndiff included in Windows zip distribution
From: Tom Sellers <nmap () fadedcode net>
Date: Wed, 04 Feb 2009 18:37:11 -0600
Here are my thoughts, untested of unfortunately. My windows boxen are not handy at the moment. It looks like you are not really modifying the PATH variable, just combining it will potential path variables in order to search for python.exe. What I would do in this case is change the "set PATH=%PATH%..." line to "set SEARCHPATH=%PATH..." Using SEARCHPATH, or any other unused variable name of your choice, avoids the need for using setlocal/endlocal to protect the environment's PATH variable. This will allow either the python return code to carry through past the end of the batch execution or let you save the python script return code and then use it to set ERRORLEVEL upon batch exit.
@echo off rem This batch file searches for a Python interpreted and uses it to run a rem script. It displays an error message if not Python is found. The script rem to run must have the same filename as the batch file, with an extension of rem .py rather than .bat.
remove the next line
setlocal rem %0 is the name of the batch file. "dpn" means drive, path, filename rem (excluding extension). set PROG=%~dpn0.py if not exist "%PROG%" ( echo Cannot run %PROG% echo because that file does not exist. exit /B 1 )
set PATH=%PATH%;C:\Python26;C:\Python25;C:\Python24
Becomes set SEARCHPATH=%PATH%;C:\Python26;C:\Python25;C:\Python24
for %%P in ( python.exe ) do set PYTHON=%%~f$PATH:P
for %%P in ( python.exe ) do set PYTHON=%%~f$SEARCHPATH:P
if not exist "%PYTHON%" ( echo Cannot run %PROG% echo because python.exe was not found anywhere in echo %PATH%.
echo %SEARCHPATH%
echo. echo To run this program, download and install Python from echo http://www.python.org/download. exit /B 1 ) "%PYTHON%" "%PROG%" %*
Remove the next line.
endlocal
I am surprised that the python installation process does not set a Windows environmental variable containing the path to its folder or .exe. Would it be better long term to rename the python script to ndiff.py? I know it would be a pain short term, but would remove the need to use and maintain batches in the future. Tom Sellers _______________________________________________ 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)