<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">execfile can't take arguments, you need
to use <i>subprocess.call</i> instead:<br>
<blockquote>import subprocess, sys<br>
subprocess.call([sys.executable, 'apt.py',
'2>mylogfile.txt'], shell=True)<br>
</blockquote>
Be careful though, `shell=True` means you can easily bork your
system if your command is misconstructed, e.g. `rmdir /s/q
C:\Windows` instead of `rmdir /s/q C:\temp\Windows` would be
disasterous.<br>
<br>
<a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/5788891/execfile-with-argument-in-python-shell">http://stackoverflow.com/questions/5788891/execfile-with-argument-in-python-shell</a><br>
<a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/912830/using-subprocess-to-run-python-script-on-windows">http://stackoverflow.com/questions/912830/using-subprocess-to-run-python-script-on-windows</a><br>
<a class="moz-txt-link-freetext" href="http://docs.python.org/library/subprocess.html">http://docs.python.org/library/subprocess.html</a><br>
<br>
cheers,<br>
<br>
<pre class="moz-signature" cols="72">matt wilkie
--------------------------------------------
Geomatics Analyst
Information Management and Technology
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
<a class="moz-txt-link-freetext" href="http://environmentyukon.gov.yk.ca/geomatics/">http://environmentyukon.gov.yk.ca/geomatics/</a>
-------------------------------------------- </pre>
On 22-Oct-2012 5:05 AM, Pietro Rossin wrote:<br>
</div>
<blockquote cite="mid:1350907506001-5010237.post@n6.nabble.com"
type="cite">
<pre wrap="">Hi again
I'm in osgeo4w shell in a python session.
I'm executing a python script with the command
execfile('myscript.py').
Is there some way to log all possible errors given by this command?
The script batch import dxf data to a postgis enabled database.
May be sometimes some file is not well recognized and many messages are
reported to the osgeo command window.
If I write
execfile('myscript.py') 2>c:\mylogfile.txt python gives me an error because
it doesn't recognize the command..
Thankyou again
Pietro
--
View this message in context: <a class="moz-txt-link-freetext" href="http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010237.html">http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010237.html</a>
Sent from the osgeo4w-dev -- OSGeo Win32 Installer List mailing list archive at Nabble.com.
_______________________________________________
osgeo4w-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:osgeo4w-dev@lists.osgeo.org">osgeo4w-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev">http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev</a>
.
</pre>
</blockquote>
<br>
</body>
</html>