December 10th, 2004, 04:23 AM
A couple of simple questions
I have two questions that I can't figure out for the life of me. Any and all help will be greatly appreciated:
1. Given the following, os.system refuses to "find" the path:
It should find C:\Program Files\Aqsis\bin\aqsis.exe The key problems lies in the space between Program and File and I can't escape a space.
os.system("C:\\Program" + " " + "\Aqsis\\bin\\aqsis.exe")
and one more question.
2. I have a program (a 3d renderer) listening on stdin. I know its listening because if i go to my prompt and type stuff in, it'll respond (with an error message saying it didn't like my gibberish). I run this python program that prints stuff to the screen (print "foo") which I assume to be stdout. Yet the renderer does not recieve the communication.
I generalized what I'm seeing to these two programs:
Run this first:
then print something to stdout, so it can be read...
# this should read from stdout
foo = sys.stdin.readline(100)
But the first program does not recieve and print out any input from stdin. What misconception am I laboring under? Thank you for your time.
sys.stdout.write("Is anyone home")
# alternatively, we could do
# print "Is anyone home?"
December 10th, 2004, 04:49 AM
The space between Program and ... what?
Originally Posted by ktpr
If it still doesn't work with 'Files' in there, then wrap the string in quotemarks such that the outer pair indicate a Python string, and the inner pair indicate to the OS behind os.system that the path is all one string, so:
December 10th, 2004, 11:31 AM
As for your second question, are you running the two python programs in different terminal windows or what? If you want the output of one program going to the input of the other, you would execute them both and connect them with a pipe (|) in the command line
$ ./outputter.py | ./inputter.py
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
December 10th, 2004, 03:19 PM
I posed my second question poorly. What I want to do with piping is open up a pipe to write to, then feed it arguments and finally have the program at the end of the pipe execute. I know this is possible but I can't isolate an example outside of a package I'm tinkering with.
In this example the DOS command md (make directory) should make a directory after being given its arguments. But it doesn't.
import sys, os
"""Encapsulates the output stream."""
def __init__(self, outstream):
self.out = outstream
"""Flush the internal buffer."""
def write(self, data):
"""Write data into the stream."""
name = "md"
outstream = os.popen(name,"w")
s = SimpleStream(outstream)
December 18th, 2004, 07:12 PM
for you first Question, I hope this help a little
Program files ==> 'progra~1'
My documents ==> "mydocu~1"
Documents and settings ==> "docume~1"