subprocess in Command promt+ webbrowser

Discussion in 'Python' started by shanti bhushan, Jun 19, 2010.

  1. I have a code ,in which i invoke the local webserver in back
    ground ,then open URL and access the web page.
    below is my code.
    I am able to invoke and kill the local webserver in seperate python
    script,but when i club opening of browser and and subprocess , my like
    below ,then my script is not responding.
    Please guide me.

    import subprocess
    import time
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    \mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
    webbrowser.open("http://43.88.79.229:8080/index.html/")
    time.sleep(11)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
    mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
    time.sleep(3)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    \mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
    webbrowser.open("http://43.88.79.229:8080/index.html/")
    time.sleep(11)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
    mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
    time.sleep(3)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    \mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
    webbrowser.open("http://43.88.79.229:8080/index.html/")
    shanti bhushan, Jun 19, 2010
    #1
    1. Advertising

  2. On Jun 19, 11:01 am, shanti bhushan <> wrote:
    > I have a code ,in which i invoke the local webserver in back
    > ground ,then open URL and access the web page.
    > below is my code.
    > I am able to invoke and kill the local webserver in seperate python
    > script,but when i club opening of browser and and subprocess , my like
    > below ,then my script is not responding.
    > Please guide me.
    >
    > import subprocess
    > import time
    > subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb\mongoose-2.8.exe >YourOutput.txt"')

    time.sleep(3)
    webbrowser.open("http://43.88.79.229:8080/index.html")
    time.sleep(11)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
    mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
    time.sleep(3)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    \mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
    time.sleep(3)
    webbrowser.open("http://43.88.79.229:8080/index.html")
    time.sleep(11)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
    mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
    time.sleep(3)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    \mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
    time.sleep(3)
    webbrowser.open("http://43.88.79.229:8080/index.html")
    time.sleep(11)
    subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
    mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground


    This scripts works fine with python 26 in windows XP, but when i
    replace the browser opening part with broswer to be open on different
    machine in python made tool.That it always give me warning that
    process already open.If i kill the the command then also it gives same
    problem.
    Please guide me is it sycronisation issue?,some exception handling is
    required??
    shanti bhushan, Jun 19, 2010
    #2
    1. Advertising

  3. On Jun 19, 11:01 am, shanti bhushan <> wrote:
    > I have a code ,in which i invoke the local webserver in back
    > ground ,then open URL and access the web page.
    > below is my code.
    > I am able to invoke and kill the local webserver in seperate python
    > script,but when i club opening of browser and and subprocess , my like
    > below ,then my script is not responding.
    > Please guide me.
    >
    > import subprocess
    > import time
    > subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    > \mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
    > webbrowser.open("http://43.88.79.229:8080/index.html/")
    > time.sleep(11)
    > subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
    > mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
    > time.sleep(3)
    > subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    > \mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
    > webbrowser.open("http://43.88.79.229:8080/index.html/")
    > time.sleep(11)
    > subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
    > mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
    > time.sleep(3)
    > subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
    > \mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
    > webbrowser.open("http://43.88.79.229:8080/index.html/")



    if i want to put exception handing for invoking the local web
    server ?? how to do that please guide
    shanti bhushan, Jun 19, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patio87
    Replies:
    4
    Views:
    414
    Julie
    Aug 18, 2004
  2. shanti bhushan

    start and kill process by command promt

    shanti bhushan, Jun 21, 2010, in forum: Python
    Replies:
    2
    Views:
    770
    Giampaolo Rodolà
    Jun 21, 2010
  3. Shyam Prakash

    Hiding cmd promt window

    Shyam Prakash, Feb 3, 2005, in forum: ASP .Net Security
    Replies:
    2
    Views:
    175
    Shyam Prakash
    Feb 4, 2005
  4. nukeymusic
    Replies:
    7
    Views:
    364
    kimma
    Dec 20, 2011
  5. Li Chen
    Replies:
    0
    Views:
    110
    Li Chen
    Nov 26, 2006
Loading...

Share This Page