butterhook
asked on
Executing python script without writing to the screen
Hello
I'm running ActivePython 2.5 (or 2.6) on Windows Server 2003.
When a script runs i.e. blahblah.py is called from the command line, even if the script does not output anything to the display, a black command line style box pops up.
Is it possible to adjust the script, or indeed the way it is called, so that it doesn't pop this box up - so it just runs in the background? There isn't really anything that the user needs to see, as the script is run by a scheduled task.
Maybe the answer is to write to a file?
Help would be much appreciated :)
I'm running ActivePython 2.5 (or 2.6) on Windows Server 2003.
When a script runs i.e. blahblah.py is called from the command line, even if the script does not output anything to the display, a black command line style box pops up.
Is it possible to adjust the script, or indeed the way it is called, so that it doesn't pop this box up - so it just runs in the background? There isn't really anything that the user needs to see, as the script is run by a scheduled task.
Maybe the answer is to write to a file?
Help would be much appreciated :)
hm... Sorry about that. I meant to attach the following image:
The following only display's stuff to the screen if myScript is imported, instead of executed.
The following only display's stuff to the screen if myScript is imported, instead of executed.
Command prompt execution of myScript.py
myScript.jpg
myScript.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi - that last answer looks exactly like what I need... will check out... Thanks
ASKER
Brilliant work!
The gelonida's suggestion is definitely the correct one. For calling it from the script, I would prefer the explicit call to pythonw.exe (just replace the call to python.exe by pythonw.exe).
The 'w' stands for "windowing application". This was created namely for executing Python application that are not "console applications", i.e. for the applications that create the GUI windows. The extra console window would otherwise look strange (say the application using the wxPython, PyQT, Tcl/Tk, or the like).
It is perfectly clean that the process runs silently (no visible output). You only should add a kind of simple logging the activity to help to discover the problems when the things go wrong.
The 'w' stands for "windowing application". This was created namely for executing Python application that are not "console applications", i.e. for the applications that create the GUI windows. The extra console window would otherwise look strange (say the application using the wxPython, PyQT, Tcl/Tk, or the like).
It is perfectly clean that the process runs silently (no visible output). You only should add a kind of simple logging the activity to help to discover the problems when the things go wrong.
ASKER
Thanks pepr - yes, I agree that in this context that some sort of file log or audit will be essential if there is no output to the screen.
If I use:
python scriptName.py parameters
it doesn't open a new command prompt.
So, how is it you are calling this script, and what does it do?
For example, the following only
Open in new window