473,763 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

commands.getsta tusoutput("FOO" ) -- won't work for me

I'm at my wits end with this silly thing. I'm new to python, so please
excuse my impending ignorance ;). I am trying to execute a command, and
get the output back into a string variable. Here's what I think should
work from the docs I've read. The system I need to get this working on is
2000 professional, I'm posting this from my linux box, so please
don't look poorly upon me for the windows thing, it wasn't my choice.

import commands

#chop
status, output = commands.getsta tusoutput("dir" )
print "Output: ", output
print "Status: ", status
#chop

"""
returns:

C:\starNE>count er.py
Output: '{' is not recognized as an internal or external command,
operable program or batch file.
Status: 1

It returns that "'{' is not recogni..." with anything I pass as a command.
"""
os.system("dir" )

works just fine, but I don't think I can capture the output, am I a victim
of a bug here?
Could it be related to this posting I googled?

http://sourceforge.net/tracker/?func...&group_id=5470

Any suggestions would be greatly appreciated!
Jul 18 '05 #1
2 7189
David Carroll <vm*****@hotmai l.com> pisze:
I'm at my wits end with this silly thing. I'm new to python, so please
excuse my impending ignorance ;). I am trying to execute a command, and
get the output back into a string variable. Here's what I think should
work from the docs I've read. The system I need to get this working on is
2000 professional, I'm posting this from my linux box, so please
don't look poorly upon me for the windows thing, it wasn't my choice.

import commands
[...]
Any suggestions would be greatly appreciated!


Module commands works only on Unix systems, as you can read in Library
Reference (Chapter 8.: Unix specific services).

--
Jarek Zgoda
Registered Linux User #-1
http://www.zgoda.biz/ JID:ja***@jabbe rpl.org http://zgoda.jogger.pl/
Jul 18 '05 #2
David Carroll wrote:
#chop
status, output = commands.getsta tusoutput("dir" )
print "Output: ", output
print "Status: ", status
#chop

"""
returns:

C:\starNE>count er.py
Output: '{' is not recognized as an internal or external command,
operable program or batch file.
Status: 1
[snip] Could it be related to this posting I googled?

http://sourceforge.net/tracker/?func...&group_id=5470

Yes, the 2.3 commands module is still Unix-only.

Use os.popen("dir") directly instead or copy the suggested fix from sf into
your module (not commands.py) to roll your own version of
getstatusoutput ().

Peter

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2479
by: Jerry Sievers | last post by:
Hello. Maybe I'm just out of practice, maybe not. Suppose we run a command using system() and this command writes to the stderr stream. If I remember correctly, this is normally written to the Apache error log file. log_errors is ON and error_reporting is 2047 E_ALL. Redirecting the stderr from the system command has it showing up on the browser output.
2
4967
by: leroybt.rm | last post by:
I don't understand why this does not work: <FILE1> test1.py #Import Packages import string # data=0 data=data+1
20
18385
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've been doing something like delete from foo where name = 'xx'; insert into foo values('xx',1,2,...);
13
4811
by: Larry Menard | last post by:
Test code: $dbconn = odbc_connect($dbname, $username, $password); $path = "C:\Temp\myJar.jar"; $statement = "CALL SQLJ.INSTALL_JAR('file://$path', 'myJarId')"; $result = odbc_exec($dbconn, $statement); Result: PHP Warning: odbc_exec(): SQL error: CLI0119E Unexpected system failure.
0
334
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 393 open (+15) / 3315 closed (+17) / 3708 total (+32) Bugs : 908 open (+22) / 5975 closed (+49) / 6883 total (+71) RFE : 223 open ( -1) / 229 closed ( +2) / 452 total ( +1) New / Reopened Patches ______________________
21
7858
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
2
1902
by: Matimus | last post by:
On Apr 11, 2:32 am, Evan <xdi...@gmail.comwrote: Do you want a custom shell that does whatever you want? Or do you want an interactive python shell that has some custom commands? For the first check out the cmd module http://docs.python.org/lib/module-cmd.html example:
9
2210
by: Krumble Bunk | last post by:
Hi all, I am trying my hands at writing a shell for unix. A very rubbish shell, but nonetheless, I come to a point where I am confused. I would like to have something like shellstop xyz whereupon the command "stop" will take the argument "xyz" and perform
0
1996
by: Gabriel Genellina | last post by:
En Thu, 25 Sep 2008 09:49:31 -0300, Almar Klein <almar.klein@gmail.com> escribió: Use subprocess.PIPE Usually the tricky part is to figure out exactly whether there is more input or not. With Python it's easy, use the ps1 prompt. --- begin --- import sys
0
10003
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9828
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8825
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7370
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3918
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3529
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2797
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.