PDA

View Full Version : [python] msdos prompt


Fuzzgtp
December 16th, 2009, 09:45 AM
I have a python script that is executing a program that is ran in the command prompt. Is there anyway to read the info that is in the msdos prompt so I can parse it? any ideas folks?

agentlame
December 16th, 2009, 10:23 AM
Never tried it, but it looks like you can get stdout using the os.spawn.subprocess


>>> subprocess.check_output(["ls", "-l", "/dev/null"])
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'

from: http://docs.python.org/3.1/library/subprocess.html


This looks newer, but same idea:
http://docs.python.org/library/subprocess.html

BTW, it really scares me that people are trying things like this.

Fuzzgtp
December 16th, 2009, 10:29 AM
Hahah, i know scary right???
Anyways, I found an easy solution. adding '> ooutput.txt' after a command echo's all the info into a text file for parsing.

Never tried it, but it looks like you can get stdout using the os.spawn.subprocess


>>> subprocess.check_output(["ls", "-l", "/dev/null"])
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'

from: http://docs.python.org/3.1/library/subprocess.html


This looks newer, but same idea:
http://docs.python.org/library/subprocess.html

BTW, it really scares me that people are trying things like this.

agentlame
December 16th, 2009, 10:34 AM
Hahah, i know scary right???
Anyways, I found an easy solution. adding '> ooutput.txt' after a command echo's all the info into a text file for parsing.

Brilliant dead-simple solution.

Now when you:

rmdir c:\*.*


You can get a list of all the files you deleted from my computer! (I kid, I kid)

joshuajonah
January 2nd, 2010, 05:44 PM
I found a better way to do this and thought I should update this thread for anybody who finds it:


import xbmc

xbmc.executebuiltin('System.Exec("opera")')

Seems to launch Opera completely independent of Boxee and forces Boxee into windowed mode.

See this page for more things you can do: http://xbmc.org/wiki/?title=List_of_Built_In_Functions

agentlame
January 2nd, 2010, 07:05 PM
I found a better way to do this and thought I should update this thread for anybody who finds it:


import xbmc

xbmc.executebuiltin('System.Exec("opera")')

Seems to launch Opera completely independent of Boxee and forces Boxee into windowed mode.

See this page for more things you can do: http://xbmc.org/wiki/?title=List_of_Built_In_Functions

Neat, but can you still get stdout?

joshuajonah
January 2nd, 2010, 08:52 PM
Nah, this would just be for launching an emulator or something.

sjml
January 12th, 2010, 12:26 PM
Are you doing this on Windows? Did you have trouble getting it to be happy with spaces in the path to the excutable? No amount of quoting seems to help out...