Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Running os.system from browser

Reply
Thread Tools

Running os.system from browser

 
 
Sean Berry
Guest
Posts: n/a
 
      07-13-2004
I have a python program that I want to
be able to run from a browser window.

It gets run in a cron job every day, but
I want my boss to be able to run it whenever
he wants to since the database it uses is
updated many times throughout the day.

I have the following as the first few lines
of a program.

#!/usr/local/bin/python
import os
os.system('/path/to/my/program.py')
print "Content-Type: text/html\n"

The rest of the program just spits out some
simple html. Ths os.system call is what is
breaking the program when I run it from a
browser, because I have commented it out
and the program works.

The program also works from the command
line. How can I fix this problem?

Thanks for any help.


 
Reply With Quote
 
 
 
 
Tim Daneliuk
Guest
Posts: n/a
 
      07-13-2004
Sean Berry wrote:

> I have a python program that I want to
> be able to run from a browser window.
>
> It gets run in a cron job every day, but
> I want my boss to be able to run it whenever
> he wants to since the database it uses is
> updated many times throughout the day.
>
> I have the following as the first few lines
> of a program.
>
> #!/usr/local/bin/python
> import os
> os.system('/path/to/my/program.py')
> print "Content-Type: text/html\n"
>
> The rest of the program just spits out some
> simple html. Ths os.system call is what is
> breaking the program when I run it from a
> browser, because I have commented it out
> and the program works.
>
> The program also works from the command
> line. How can I fix this problem?
>
> Thanks for any help.
>
>


At first glance, this suggests itself:


os.system('/path/to/python /path/to/my/program.py')

I
--
----------------------------------------------------------------------------
Tim Daneliuk http://www.velocityreviews.com/forums/(E-Mail Removed)
PGP Key: http://www.tundraware.com/PGP/
 
Reply With Quote
 
 
 
 
Fuzzyman
Guest
Posts: n/a
 
      07-13-2004
"Sean Berry" <(E-Mail Removed)> wrote in message news:<jRGIc.5063$%w5.1899@okepread05>...
> I have a python program that I want to
> be able to run from a browser window.
>
> It gets run in a cron job every day, but
> I want my boss to be able to run it whenever
> he wants to since the database it uses is
> updated many times throughout the day.
>
> I have the following as the first few lines
> of a program.
>
> #!/usr/local/bin/python
> import os
> os.system('/path/to/my/program.py')
> print "Content-Type: text/html\n"
>
> The rest of the program just spits out some
> simple html. Ths os.system call is what is
> breaking the program when I run it from a
> browser, because I have commented it out
> and the program works.
>
> The program also works from the command
> line. How can I fix this problem?
>
> Thanks for any help.


I recently wrote a CGI that executes shell commands retrieved from a
HTML form.
It would fail (the dreaded internal error 500) when I used os.system
- but would work fine if I used os.popen2
It's likely that something similar is happening... although perhaps
someone more server savvy could confirm/explain.

Regards,

Fuzzy

http://www.voidspace.org.uk/atlantib...thonutils.html
 
Reply With Quote
 
Thomas Guettler
Guest
Posts: n/a
 
      07-13-2004
Am Mon, 12 Jul 2004 18:25:07 -0700 schrieb Sean Berry:

> I have a python program that I want to
> be able to run from a browser window.


> I have the following as the first few lines
> of a program.
>
> #!/usr/local/bin/python
> import os
> os.system('/path/to/my/program.py')
> print "Content-Type: text/html\n"


> The program also works from the command
> line. How can I fix this problem?


os.system() writes to stdout. This means if your
programm.py write to stdout it is send to the browser.

Use os.system('.. >> logfile 2>&1') or popen4

HTH,
Thomas

--
Thomas GŁttler, http://www.thomas-guettler.de/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running,Running! audit2 Firefox 1 02-01-2008 09:27 PM
Running into MTU issues with VPN running on Cisco 7206VXR amit1017 Cisco 1 10-18-2007 01:03 PM
modify a long-running python script while it is running? Benjamin Rutt Python 2 12-20-2005 01:42 PM
Running a C# program w/GUI through a web browser Magnus Gran-Jansen ASP .Net 0 05-10-2005 07:51 AM
I'm trying to network a deasktop running 98SE and a laptop running XP. Marc Computer Support 8 11-19-2003 03:01 AM



Advertisments