473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

python system subprocess win32

Hello ALl,
I have a compiled program "conv.exe" that works as follows:
>>conv.exe
-----------------------------
Please selection from the following options. press "h" for help, "p" for
print, "r" for readfile.
Enter your request now:
....
--------------------
Is there a way to script python using the subprocess method to start this
program "conv.exe" and then send a "r" to the command line to make it, say,
readfile.

I have tried the following but the .communicate("r) is not doing anything

import subprocess
import time

a=subprocess.Popen("c:\\mcml\\conv.exe")
time.sleep(1)
(stdout, stderr) = a.communicate("r")

Many thanks,
Bryan
Aug 7 '07 #1
3 1835
On Aug 7, 9:48 am, "mclaugb" <mcla...@nospm.yahoo.comwrote:
Hello ALl,
I have a compiled program "conv.exe" that works as follows:>>conv.exe

-----------------------------
Please selection from the following options. press "h" for help, "p" for
print, "r" for readfile.
Enter your request now:
...
--------------------
Is there a way to script python using the subprocess method to start this
program "conv.exe" and then send a "r" to the command line to make it, say,
readfile.

I have tried the following but the .communicate("r) is not doing anything

import subprocess
import time

a=subprocess.Popen("c:\\mcml\\conv.exe")
time.sleep(1)
(stdout, stderr) = a.communicate("r")

Many thanks,
Bryan
Use the sys.argv method. In the code that you have compiled, put the
following lines in:

<code>

import sys
default = sys.argv[1]
if default:
# check which option it is and run it appropriately
else:
# print your menu here

</code>

Then you should be able to do the subprocess Popen command:

subprocess.Popen("c:\\mcml\\conv.exe r")

You may need to turn the shell on...

subprocess.Popen("c:\\mcml\\conv.exe r", shell=True)

Hopefully that gives you some ideas anyway.

Mike

Aug 7 '07 #2
At the moment, I cannot figure a way of running this precompiled "conv.exe"
using commandline arguments.

Thus, I need Python to call the program, wait until it loads up, then enter
a known sequence of characters so that the function will run.
The program conv.exe I call looks like this.
--------------------------
Welcome to conv.exe
This program was written by ....

Please select from the following options: h- (help) r- (read) ...etc
Enter your request:
---------------------------------
I need Python to start the program, wait a second and then issue a few
characters to the program.

Hope this makes more sense!
Bryan

<ky******@gmail.comwrote in message
news:11**********************@e9g2000prf.googlegro ups.com...
On Aug 7, 9:48 am, "mclaugb" <mcla...@nospm.yahoo.comwrote:
>Hello ALl,
I have a compiled program "conv.exe" that works as follows:>>conv.exe

-----------------------------
Please selection from the following options. press "h" for help, "p" for
print, "r" for readfile.
Enter your request now:
...
--------------------
Is there a way to script python using the subprocess method to start this
program "conv.exe" and then send a "r" to the command line to make it,
say,
readfile.

I have tried the following but the .communicate("r) is not doing anything

import subprocess
import time

a=subprocess.Popen("c:\\mcml\\conv.exe")
time.sleep(1)
(stdout, stderr) = a.communicate("r")

Many thanks,
Bryan

Use the sys.argv method. In the code that you have compiled, put the
following lines in:

<code>

import sys
default = sys.argv[1]
if default:
# check which option it is and run it appropriately
else:
# print your menu here

</code>

Then you should be able to do the subprocess Popen command:

subprocess.Popen("c:\\mcml\\conv.exe r")

You may need to turn the shell on...

subprocess.Popen("c:\\mcml\\conv.exe r", shell=True)

Hopefully that gives you some ideas anyway.

Mike

Aug 7 '07 #3
On Aug 7, 11:07 am, "mclaugb" <mcla...@nospm.yahoo.comwrote:
At the moment, I cannot figure a way of running this precompiled "conv.exe"
using commandline arguments.

Thus, I need Python to call the program, wait until it loads up, then enter
a known sequence of characters so that the function will run.
The program conv.exe I call looks like this.
--------------------------
Welcome to conv.exe
This program was written by ....

Please select from the following options: h- (help) r- (read) ...etc
Enter your request:
---------------------------------
I need Python to start the program, wait a second and then issue a few
characters to the program.

Hope this makes more sense!
Bryan

<kyoso...@gmail.comwrote in message

news:11**********************@e9g2000prf.googlegro ups.com...
On Aug 7, 9:48 am, "mclaugb" <mcla...@nospm.yahoo.comwrote:
Hello ALl,
I have a compiled program "conv.exe" that works as follows:>>conv.exe
-----------------------------
Please selection from the following options. press "h" for help, "p" for
print, "r" for readfile.
Enter your request now:
...
--------------------
Is there a way to script python using the subprocess method to start this
program "conv.exe" and then send a "r" to the command line to make it,
say,
readfile.
I have tried the following but the .communicate("r) is not doing anything
import subprocess
import time
a=subprocess.Popen("c:\\mcml\\conv.exe")
time.sleep(1)
(stdout, stderr) = a.communicate("r")
Many thanks,
Bryan
Use the sys.argv method. In the code that you have compiled, put the
following lines in:
<code>
import sys
default = sys.argv[1]
if default:
# check which option it is and run it appropriately
else:
# print your menu here
</code>
Then you should be able to do the subprocess Popen command:
subprocess.Popen("c:\\mcml\\conv.exe r")
You may need to turn the shell on...
subprocess.Popen("c:\\mcml\\conv.exe r", shell=True)
Hopefully that gives you some ideas anyway.
Mike
Oh. I thought you had compiled the program yourself. I suppose you
could use SendKeys then. I have a couple links here:

http://pythonlibrary.org/python/SendKeys

It's pretty hackneyed, but I've used the SendKeys module to automate
Firefox to some degree.

Mike

Aug 7 '07 #4

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

Similar topics

2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 421 open ( +3) / 3530 closed ( +8) / 3951 total (+11) Bugs : 963 open ( +4) / 6426 closed (+21) / 7389 total (+25) RFE : 255 open...
7
by: Jonathan Fine | last post by:
Hello My problem is that I want a Python 2.4 module on a server that is running Python 2.3. I definitely want to use the 2.4 module, and I don't want to require the server to move to Python...
4
by: Aidan | last post by:
Hi, I'm having a bit of trouble with a python script I wrote, though I'm not sure if it's related directly to python, or one of the other software packages... The situation is that I'm trying...
10
by: bruce | last post by:
hi... can someone point me to where/how i would go about calling a ruby app from a python app, and having the python app being able to get a returned value from the ruby script. something...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.