Member Avatar for sravan953

Hey guys....

I use Python 2.6.2. I recently created a program which accepts commands from my website, here's the code I used:

import urllib
import subprocess
import time

open_site=urllib.urlopen("http://www.sravan953.webs.com/command_python.htm")
read_site=open_site.read()

def run_program():
    current=time.asctime()
    print 'Runnning program'+' ['+current+']'
    subprocess.call(read_site)

def check_argument():
    current=time.asctime()
    if read_site=='':
        print 'No command given'+' ['+current+']'
        timer()
    else:
        print 'Command found...'+' ['+current+']'
        run_program()

def timer():
    current=time.asctime()
    print 'Checking for commands...'+' ['+current+']'
    time.sleep(2)
    check_argument()

timer()

But when I run it I get an error:

Traceback (most recent call last):
File "C:\Documents and Settings\Sravan\My Documents\Sravan\PYTHON\Accepshun.py", line 28, in <module>
timer()
File "C:\Documents and Settings\Sravan\My Documents\Sravan\PYTHON\Accepshun.py", line 26, in timer
check_argument()
File "C:\Documents and Settings\Sravan\My Documents\Sravan\PYTHON\Accepshun.py", line 20, in check_argument
run_program()
File "C:\Documents and Settings\Sravan\My Documents\Sravan\PYTHON\Accepshun.py", line 11, in run_program
subprocess.call("C:\Program Files\Mozilla Firefox 3.1 Beta 3\firefox.exe")
File "C:\Python26\lib\subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python26\lib\subprocess.py", line 595, in __init__
errread, errwrite)
File "C:\Python26\lib\subprocess.py", line 804, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

I only recently uninstalled Python 2.6.2 and re-installed it again, and then installed py2exe....it used to work fine before I uninstalled it, is there anything else I have to install?

Thanks for the help guys...

subprocess.call(["program-name", "arg1", "arg2"]) takes an executable program with arguments.

You are giving it an html script code. That won't work!

Member Avatar for sravan953

subprocess.call(["program-name", "arg1", "arg2"]) takes an executable program with arguments.

You are giving it an html script code. That won't work!

Yeah but, I have made sure that in the webpage, there is only text and no HTML tags...so basically it should work right?

Run this little test code, it's the beginning of your program ...

import urllib

url = "http://www.sravan953.webs.com/command_python.htm"
open_site = urllib.urlopen(url)
read_site = open_site.read()

print(read_site)

The only thing you can execute this result with is a web browser.
You can run the url directly using the Python module webbrowser ...

import webbrowser

url = "http://www.sravan953.webs.com/command_python.htm"
webbrowser.open(url)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.