![]() |
how to send commands to a prompt?
I'm looking to create a python script that executes dos promt commands which launch another program that runs out of the dos shell, then run commands on that program. If someone could point me to the best mods to investigate and some example code or tutorials I'd be so greatful.
The following are a few esential commands I'm wanting to execute at the prompt: #1. hscript file.hip #is the first command, this launches hscript and loads the file.hip as the current scene, hscript is a non gui version of a 3d ap. *.hip is a scene file we're now inside of. #2 cd /obj/model1 #is the second command, this looks like unix but is hscript (similar to unix) and takes me into a 3d object within the *.hip scene file. #3 opparm -d sphere1 tx #is the third command, this reads the parameter value for translation X for the sphere object. Finaly to output the result of the third command to a file. Is seems like it should be very simple, but I am new to scripting and need a little guidence. Thank you in advance to anyone who can help acab |
Not sure if this is what you are looking for, but check out the docs on process management, especially exec or spawn for running new programs.
|
Thank you Moldz for the tip, but its still not to clear, I find that often times tech notes make little sense in the beggining when I'm first learning something and over time they make more and more sense.
So, if anyone could give me an example of how process managment could help... I need examples... thanx acab |
Ok, I was intrigued enough to dig a little deeper. You need to check out the popen2 module.
It allows you to start a program and get a reference to its input and output. It's really easy to read the output of a program and really easy to send input to a program, but really tricky to do both. Try something like this: :
import popen2 |
Hey Moldz, you rock... That gets me so close. Though right now I've decided to focus on learning the basics, that why its taken me so long to reply to your latest post, I just haven't seen it tell now. But even now I don't entirely understand your example code which tells me that I'm doing the right thing by focusing on the basics. Once I'm a little more familiar with Python and programing in general I'll be back.
Thanks again acab |
| All times are GMT -5. The time now is 4:26 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC