Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Getting output from executed command that is not STDIN

Reply
Thread Tools

Getting output from executed command that is not STDIN

 
 
Sami Viitanen
Guest
Posts: n/a
 
      08-07-2003
Hello,

I'm using os.popen and read for reading command input to string but the
string doesn't contain the same output that running the command manually or
with os.system contains.

with os.system:
cvs server: Diffing //Project1
File //Project1/testiware.txt is new; current revision 3.13
File //Project1/what_is_version_control.txt is new; current revision 3.3
cvs server: Diffing //Project1/Dir1
File //Project1/Dir1/seltest.c is new; current revision 1.4
File //Project1/Dir1/testi.c is new; current revision 1.2

with os.popen and read:
File //Project1/testiware.txt is new; current revision 3.13
File //Project1/what_is_version_control.txt is new; current revision 3.3
File //Project1/Dir1/seltest.c is new; current revision 1.4
File //Project1/Dir1/testi.c is new; current revision 1.2

---
Script doesn't read those "cvs server: Diffing" lines
---


 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      08-07-2003
Sami Viitanen wrote:

> I'm using os.popen and read for reading command input to string but the
> string doesn't contain the same output that running the command manually or
> with os.system contains.
>
> with os.system:
> cvs server: Diffing //Project1
> File //Project1/testiware.txt is new; current revision 3.13
> File //Project1/what_is_version_control.txt is new; current revision 3.3
> cvs server: Diffing //Project1/Dir1
> File //Project1/Dir1/seltest.c is new; current revision 1.4
> File //Project1/Dir1/testi.c is new; current revision 1.2
>
> with os.popen and read:
> File //Project1/testiware.txt is new; current revision 3.13
> File //Project1/what_is_version_control.txt is new; current revision 3.3
> File //Project1/Dir1/seltest.c is new; current revision 1.4
> File //Project1/Dir1/testi.c is new; current revision 1.2
>
> ---
> Script doesn't read those "cvs server: Diffing" lines
> ---


looks like the program prints some output to stderr, and some to stdout.
possible solutions:

1) if your shell supports it, add "2>&1" to the end of the command line,
to send all stderr output to stdout. random google link:
http://www.zeitfenster.de/bash/Bash-...o-HOWTO-3.html

2) use os.popen4 to get a file handle representing both streams. see:
http://www.python.org/doc/current/li...#os-newstreams

</F>

<!-- (the eff-bot guide to) the python standard library (redux):
http://effbot.org/zone/librarybook-index.htm
-->




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
peek at stdin, flush stdin Johnathan Doe C Programming 5 3 Days Ago 04:30 PM
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Getting returncode of a command executed with Popen through xterm AmFreak@web.de Python 2 10-19-2010 09:37 PM
How to pass stdin of a C++ program to the stdin of a process createdwith ShellExecute() Ben C Programming 2 08-29-2009 09:47 PM
Reading stdin once confuses second stdin read Charlie Zender C Programming 6 06-21-2004 01:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57