Ok, thanks<div>I'll try...</div><div>Bie</div><div>Pietro<br><br><div class="gmail_quote">2012/10/22 Matt Wilkie-2 [via OSGeo.org] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=5010502&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>></span><br>
<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">

        
  
    
  
  
    <div>execfile can't take arguments, you need
      to use <i>subprocess.call</i> instead:<br>
      <blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em">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 href="http://stackoverflow.com/questions/5788891/execfile-with-argument-in-python-shell" rel="nofollow" link="external" target="_blank">http://stackoverflow.com/questions/5788891/execfile-with-argument-in-python-shell</a><br>

<a href="http://stackoverflow.com/questions/912830/using-subprocess-to-run-python-script-on-windows" rel="nofollow" link="external" target="_blank">http://stackoverflow.com/questions/912830/using-subprocess-to-run-python-script-on-windows</a><br>

      <a href="http://docs.python.org/library/subprocess.html" rel="nofollow" link="external" target="_blank">http://docs.python.org/library/subprocess.html</a><br>
      <br>
      cheers,<br>
      <br>
      <pre cols="72">matt wilkie
--------------------------------------------
Geomatics Analyst
Information Management and Technology
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
<a href="tel:867-667-8133" value="+18676678133" target="_blank">867-667-8133</a> Tel * <a href="tel:867-393-7003" value="+18673937003" target="_blank">867-393-7003</a> Fax
<a href="http://environmentyukon.gov.yk.ca/geomatics/" rel="nofollow" link="external" target="_blank">http://environmentyukon.gov.yk.ca/geomatics/</a>
-------------------------------------------- </pre>
      On 22-Oct-2012 5:05 AM, Pietro Rossin wrote:<br>
    </div>
    </div><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" type="cite">
      <pre>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 href="http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010237.html" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010237.html</a><div class="im">

Sent from the osgeo4w-dev -- OSGeo Win32 Installer List mailing list archive at Nabble.com.
_______________________________________________
osgeo4w-dev mailing list
</div><div class="im"><a href="http://user/SendEmail.jtp?type=node&node=5010342&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<a href="http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev</a>
.

</div></pre>
    </blockquote><div class="im">
    <br>
  

<br>_______________________________________________
<br>osgeo4w-dev mailing list
<br><a href="http://user/SendEmail.jtp?type=node&node=5010342&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev</a><br>

        
        
        
        <br>
        <br>
        </div><hr noshade size="1" color="#cccccc">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif"><div class="im">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                </div><a href="http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010342.html" target="_blank" rel="nofollow" link="external">http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010342.html</a>
        </div><div class="HOEnZb"><div class="h5">
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from How to log Osgeo4W shell stdout into a txt file?, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>

                <a href="http://osgeo-org.1560.n6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
        </div></div></div></blockquote></div><br></div>


        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010502.html">Re: How to log Osgeo4W shell stdout into a txt file?</a><br/>
Sent from the <a href="http://osgeo-org.1560.n6.nabble.com/osgeo4w-dev-OSGeo-Win32-Installer-List-f3765018.html">osgeo4w-dev -- OSGeo Win32 Installer List mailing list archive</a> at Nabble.com.<br/>