By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,429 Members | 1,088 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,429 IT Pros & Developers. It's quick & easy.

Best way to capture output from an exec'ed (or such) script?

P: n/a
Hey everyone,
I'm writing a tiny web server, mostly to learn - security and such is
a non-issue, but learning how to make things secure is of course nice
too. To be clear - I will most likely not even use it myself.

In any case. I've added some minor scripting support, so that you can
write dynamic pages in Python. To do this, I use execfile(), and pass
the script a dictionary with some basic variables. The script then
sets a "ret" variable that's sent back to the browser. That's some
major ugliness right there! If I do a "print" inside the script, then
it'll end up on the server console. I want it to end up in the web

How would I accomplish this, i.e. redirect the standard output to
somewhere else, such as a variable in the calling script? If it's not
easy (as in, quite trivial) just say so. I've been thinking about
popen(2,3,4) but that's almost as ugly, if not even worse, than the
current "solution".

Thanks in advance.

Aug 2 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.