473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Running os.system from browser

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.
Jul 18 '05 #1
3 1644
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 tu****@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
Jul 18 '05 #2
"Sean Berry" <se********@cox.net> 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
Jul 18 '05 #3
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/
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John | last post by:
I am trying to spawn a seperate process from my asp page so when a user clicks the link or button a desktop program is launched. This will be on an intranet and the program will exist on the...
8
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think...
4
by: Randy | last post by:
Hi, ok, I found a way to connect to a running instance of an (external) Internet Explorer and access - for example - the html source. That works fine! But now I have running application with...
3
by: Ken Dopierala Jr. | last post by:
Hi, I once saw a thread on running a .Net Windows Application through a browser on a system with the .Net framework installed. However I can't find any resources on that. Does anyone have any...
5
by: merry.sailor | last post by:
Hello, I am using python and CGI to initiate a long running simulation (up to 5h long) on a remote machine. The main idea is that I use a form, enter the parameters and a CGI scripts start the...
5
by: jeremy | last post by:
I have an ASP.Net 2.0 application running on Windows Server 2003. The application displays properly in Internet Explorer, however, when I use a browser control embedded in a .net form, I get an...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
5
by: This | last post by:
I have a pretty basic emailing script that sends a relatively small number (150) of html emails. The emails are compiled, personalised from a mysql db subscribers list, and sent using mail() -...
22
by: V S Rawat | last post by:
(bringing the discussion here for php.general) I am on xpsp3, wampserver 2.0, having apache 2.2.8, php 5.2.6, MySQL 5.0.51b. http://localhost/ is E:\wamp\www\ I have put the first php script...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.