[osgeo4w-dev] How to log Osgeo4W shell stdout into a txt file?

Pietro Rossin pierigis at gmail.com
Tue Oct 23 07:11:58 PDT 2012


Ok, thanks
I'll try...
Bie
Pietro

2012/10/22 Matt Wilkie-2 [via OSGeo.org] <
ml-node+s1560n5010342h47 at n6.nabble.com>

> execfile can't take arguments, you need to use *subprocess.call* instead:
>
> import subprocess, sys
> subprocess.call([sys.executable, 'apt.py', '2>mylogfile.txt'], shell=True)
>
> 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.
>
>
> http://stackoverflow.com/questions/5788891/execfile-with-argument-in-python-shell
>
> http://stackoverflow.com/questions/912830/using-subprocess-to-run-python-script-on-windows
> http://docs.python.org/library/subprocess.html
>
> cheers,
>
> matt wilkie
> --------------------------------------------
> Geomatics Analyst
> Information Management and Technology
> Yukon Department of Environment
> 10 Burns Road * Whitehorse, Yukon * Y1A 4Y9867-667-8133 Tel * 867-393-7003 Faxhttp://environmentyukon.gov.yk.ca/geomatics/
> --------------------------------------------
>
> On 22-Oct-2012 5:05 AM, Pietro Rossin wrote:
>
> 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: http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010237.html
>
> Sent from the osgeo4w-dev -- OSGeo Win32 Installer List mailing list archive at Nabble.com.
> _______________________________________________
> osgeo4w-dev mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=5010342&i=0>http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev
> .
>
>
>
>
> _______________________________________________
> osgeo4w-dev mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=5010342&i=1>
> http://lists.osgeo.org/mailman/listinfo/osgeo4w-dev
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010342.html
>  To unsubscribe from How to log Osgeo4W shell stdout into a txt file?, click
> here<http://osgeo-org.1560.n6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5009568&code=cGllcmlnaXNAZ21haWwuY29tfDUwMDk1Njh8MjMwODY1MTQ5>
> .
> NAML<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>
>




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-log-Osgeo4W-shell-stdout-into-a-txt-file-tp5009568p5010502.html
Sent from the osgeo4w-dev -- OSGeo Win32 Installer List mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/osgeo4w-dev/attachments/20121023/30abe3eb/attachment.html>


More information about the osgeo4w-dev mailing list