473,575 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Po pen("c:\\mcml\\ conv.exe")
time.sleep(1)
(stdout, stderr) = a.communicate(" r")

Many thanks,
Bryan
Aug 7 '07 #1
3 1847
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.Po pen("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.Pope n("c:\\mcml\\co nv.exe r")

You may need to turn the shell on...

subprocess.Pope n("c:\\mcml\\co nv.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.goog legroups.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.P open("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.Pope n("c:\\mcml\\co nv.exe r")

You may need to turn the shell on...

subprocess.Pope n("c:\\mcml\\co nv.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.goog legroups.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.Po pen("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.Pope n("c:\\mcml\\co nv.exe r")
You may need to turn the shell on...
subprocess.Pope n("c:\\mcml\\co nv.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
4540
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 the function due to its
0
219
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 ( +5) / 246 closed ( +1) / 501 total ( +6) New / Reopened Patches ______________________
7
1854
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 2.4. More exactly, I am using subprocess, which is new in Python 2.4. What I am writing is something like
4
3936
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 to create a system backup script that creates an image of the system, filters the output though gzip, and then uploads the data (via ftp) to a...
10
1495
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 like test.py a = os.exec(testruby.rb)
0
8120
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8281
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...
1
7868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8143
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...
1
5664
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...
0
5338
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...
0
3778
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3797
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2286
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

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.