[Tutor] captering output of a cmd run using os.system.

Praveen Pathiyil ppathiyi@cisco.com
Fri, 1 Jun 2001 14:38:52 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_0116_01C0EAA8.943C9EE0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

captering output of a cmd run using os.system.You can use the os.popen3 =
command instead.
This gives you access to the stdin, stdout and stderr of the command.

                std_out, std_in, std_err =3D popen2.popen3(line)
                resp_suc =3D std_out.readlines()
                resp_err =3D std_err.readlines()
Where "line" will be your command.

Rgds,
Praveen.

  ----- Original Message -----=20
  From: GADGIL PRASAD /INFRA/INFOTECH=20
  To: 'tutor@python.org'=20
  Sent: Friday, June 01, 2001 2:00 PM
  Subject: [Tutor] captering output of a cmd run using os.system.


  hello,=20

  a cmd that I run using os.sustem() gives the output that I want to =
assign to a var=20
  and use later in prog. How do I do that ?=20

  regards,=20
  prasad=20



  ..=20


------=_NextPart_000_0116_01C0EAA8.943C9EE0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>captering output of a cmd run using =
os.system.</TITLE>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>You can use the os.popen3 command=20
instead.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This gives you access to the stdin, =
stdout and=20
stderr of the command.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
std_out, std_in, std_err =3D=20
popen2.popen3(line)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
resp_suc =3D=20
std_out.readlines()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
resp_err =3D std_err.readlines()<BR>Where "line" will be your=20
command.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Rgds,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Praveen.</FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A href=3D"mailto:GADGILP@INFOTECH.ICICI.com"=20
  title=3DGADGILP@INFOTECH.ICICI.com>GADGIL PRASAD /INFRA/INFOTECH</A> =
</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:'tutor@python.org'"=20
  title=3Dtutor@python.org>'tutor@python.org'</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, June 01, 2001 =
2:00 PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] captering =
output of a=20
  cmd run using os.system.</DIV>
  <DIV><BR></DIV>
  <P><FONT size=3D2>hello,</FONT> </P>
  <P><FONT size=3D2>a cmd that I run using os.sustem() gives the output =
that I=20
  want to assign to a var </FONT><BR><FONT size=3D2>and use later in =
prog. How do=20
  I do that ?</FONT> </P>
  <P><FONT size=3D2>regards,</FONT> <BR><FONT size=3D2>prasad</FONT> =
</P><BR>
  <P><B><FONT size=3D2>.. </FONT></B></P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0116_01C0EAA8.943C9EE0--