[Tutor] os.popen: writing to

James Lockley jpl@global.co.za
Wed, 31 Jan 2001 13:40:54 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0010_01C08B8B.6F0816D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi all

am tryng to automate a process using python to control the calling.  At =
the moment have pythin calling windows batch files using os.popen, which =
works fine.

i now want to go to the next step and get rid of the batch files...
i need to open a pipe to a command and then write the command arguments =
to it.

as far as i could make out from the documentation, this should work:

>>> abaqus=3D'c:\\abaqus\\5.8-14\\abaqus.exe'
>>> abq=3Dos.popen(abaqus,'w')
>>> abq.write('post')

but i get this:

Traceback (innermost last):
  File "<interactive input>", line 1, in ?
IOError: [Errno 22] Invalid argument

(this in a dos window works fine: =
D:\Work\Current>c:\abaqus\5.8-14\abaqus.exe post)

thanks in anticipation
james

P.S. any idea where to find out what the error numbers corelate to ?

-------------------------------------------------------------------------=
------
Ever stop to think and then forget to start again........?
-------------------------------------------------------------------------=
------

------=_NextPart_000_0010_01C08B8B.6F0816D0
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>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3105.105" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>hi all</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>am tryng to automate a process using =
python to=20
control the calling.&nbsp; At the moment have pythin calling windows =
batch files=20
using os.popen, which works fine.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>i now want to go to the next step and =
get rid of=20
the batch files...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i need to open a pipe to a command and =
then write=20
the command arguments to it.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>as far as i could make out from the =
documentation,=20
this should work:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; abaqus=3D<FONT=20
color=3D#008080>'c:\\abaqus\\5.8-14\\abaqus.exe'<BR></FONT>&gt;&gt;&gt;=20
abq=3Dos.popen(abaqus,'<FONT color=3D#008080>w</FONT>')<BR>&gt;&gt;&gt;=20
abq.write('<FONT color=3D#008080>post</FONT>')</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>but i get this:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000 face=3DArial size=3D2>Traceback (innermost =
last):<BR>&nbsp;=20
File "&lt;interactive input&gt;", line 1, in ?<BR>IOError: [Errno 22] =
Invalid=20
argument</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>(this in a dos window works fine:=20
D:\Work\Current&gt;c:\abaqus\5.8-14\abaqus.exe post)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks in anticipation</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>james</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>P.S. any idea where to find out what =
the error=20
numbers corelate to ?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
---------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Ever stop to think and then forget to =
start=20
again........?</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
---------------</FONT></DIV></BODY></HTML>

------=_NextPart_000_0010_01C08B8B.6F0816D0--