Re: os.system(cmd) isn't working
Terry Hancock wrote: > On Thursday 23 June 2005 01:19 am, Paul Watson wrote: > >>"Gregory Piñero" <[EMAIL PROTECTED]> wrote in message >>news:[EMAIL PROTECTED] >>os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' >>"www.blendedtechnologies.com"') >> > You don't have any spaces between the command and the argument, I spent a while trying to prove that to myself as well, but eventually I concluded that the fact that the ' and the " after the plus sign are on separate lines must mean that there was whitespace between them, or the line break would have occurred before the ' ... but it did seem like a good theory while it lasted. ;-) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system(cmd) isn't working
On Thursday 23 June 2005 01:19 am, Paul Watson wrote: > "Gregory Piñero" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' > "www.blendedtechnologies.com"') > > The goal is to have firefox open to that website. You don't have any spaces between the command and the argument, I would assume they'd be necessary. I also notice you are quoting the quotes here, so I presume you actually need them (maybe this is because you have an embedded space in the filename?). Need I mention that using filenames with spaces is a great evil? ;-) -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system(cmd) isn't working
Thanks to everyone for all the help! After careful consideration I decided to go with os.startfile(url) It works just great! Here's my program in case anyone's interested. 5 points if you can guess what it does ;-) """Take a filepath from stdin and translate to the corresponding url and open up browser and show it.""" import sys import os myhtmlroot='C:\\Documents and Settings\\Gregory\\My Documents\\blendedtechnologies\\trunk' htmlroot='http://www.blendedtechnologies.com' filepath=sys.argv[1] filename=os.path.basename(filepath) filedir=os.path.dirname(filepath).replace(myhtmlroot,'').replace('\\','/') url=htmlroot+'/'+filedir+'/'+filename os.startfile(url) -Greg On 23 Jun 2005 10:04:32 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > If firefox is not your default browser, > os.system(r'"cd c:\Program Files\Mozilla Firefox & firefox "' + > '"www.blendertechnologies.com "') > > works for me. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system(cmd) isn't working
If firefox is not your default browser, os.system(r'"cd c:\Program Files\Mozilla Firefox & firefox "' + '"www.blendertechnologies.com"') works for me. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system(cmd) isn't working
On Thu, 23 Jun 2005 00:02:55 -0400, Gregory Piñero <[EMAIL PROTECTED]> wrote: >Hi guys, > >I'm trying to run this statement: > >os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' >"www.blendedtechnologies.com"') > >The goal is to have firefox open to that website. > >When I type r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' >"www.blendedtechnologies.com"' in the python interpreter I get: > >'"C:\\Program Files\\Mozilla Firefox\\firefox.exe" >"www.blendedtechnologies.com"' > >And when I copy this into my command prompt (less outermost ' ) >firefox opens up to that page like I would expect. However in python >nothing happens and I get exit status 1. > >I'm using Python 2.3 on Windows XP pro service pack 2. What is wrong with: os.startfile("www.blendedtechnologies.com") -- http://mail.python.org/mailman/listinfo/python-list
RE: os.system(cmd) isn't working
[Michael P. Soulier] | On 23/06/05 Tim Golden said: | | > This is only half an answer, but I personally find faffing | > about with the double-quote / double-backslash stuff between | > Python and Windows a pain in the neck, so where I can I avoid it. | | Indeed. I believe this is why Python has os.sep. | | Mike Well, true, but if you were trying to enter a particular file path as the OP was (c:\program files\ etc.) would you really want to have "c:" + os.sep + "program files"... or os.path.join ("c:", "program files"...)? And where do the double-quotes go etc? I'm not saying all these things aren't possible; my only point is that rather than try to remember / work it out, I generally try to avoid the issue. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system(cmd) isn't working
On 23/06/05 Tim Golden said: > This is only half an answer, but I personally find faffing > about with the double-quote / double-backslash stuff between > Python and Windows a pain in the neck, so where I can I avoid it. Indeed. I believe this is why Python has os.sep. Mike -- Michael P. Soulier <[EMAIL PROTECTED]> http://www.digitaltorque.ca http://opag.ca python -c 'import this' Jabber: [EMAIL PROTECTED] signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system(cmd) isn't working
Le Thu, 23 Jun 2005 01:19:11 -0500, Paul Watson a écrit : > "Gregory Piñero" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Hi guys, > > I'm trying to run this statement: > > os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' > "www.blendedtechnologies.com"') > > The goal is to have firefox open to that website. I suggest to use the subprocess module. You don't have insert " around a path with embedded spaces and you can give the exact executable pathname, set the directory for the child process, etc import os import os.path import subprocess path_exe = r'C:\Program Files\Mozilla Firefox\firefox.exe' assert os.path.exists(path_exe) url = "http://www.blendedtechnologies.com"; child = subprocess.Popen( (path_exe, url), executable = path_exe) rc = child.wait() > I'm using Python 2.3 on Windows XP pro service pack 2. I think that subprocess is a new Python2.4 module, but you should be able to find a 2.3 version (perhaps effbot.org) > > I'd greatly appriciate any help. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system(cmd) isn't working
"Gregory Piñero" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi guys, I'm trying to run this statement: os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' "www.blendedtechnologies.com"') The goal is to have firefox open to that website. When I type r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' "www.blendedtechnologies.com"' in the python interpreter I get: '"C:\\Program Files\\Mozilla Firefox\\firefox.exe" "www.blendedtechnologies.com"' And when I copy this into my command prompt (less outermost ' ) firefox opens up to that page like I would expect. However in python nothing happens and I get exit status 1. I'm using Python 2.3 on Windows XP pro service pack 2. I'd greatly appriciate any help. Thanks, Greg === These seemed to work on one machine for Python 2.1 and 2.4. >>> os.system('\"C:/Program Files/Mozilla Firefox/firefox.exe\" >>> http://www.blendedtechnologies.com/') 1 >>> os.system('\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" >>> http://www.blendedtechnologies.com/') 1 >>> os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe" >>> http://www.blendedtechnologies.com/') 1 -- http://mail.python.org/mailman/listinfo/python-list
RE: os.system(cmd) isn't working
[Gregory Piñero] | | I'm trying to run this statement: | | os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' | "www.blendedtechnologies.com"') | | The goal is to have firefox open to that website. | | When I type r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' | "www.blendedtechnologies.com"' in the python interpreter I get: | | '"C:\\Program Files\\Mozilla Firefox\\firefox.exe" | "www.blendedtechnologies.com"' | | And when I copy this into my command prompt (less outermost ' ) | firefox opens up to that page like I would expect. However in python | nothing happens and I get exit status 1. This is only half an answer, but I personally find faffing about with the double-quote / double-backslash stuff between Python and Windows a pain in the neck, so where I can I avoid it. In this case, you have a few options: 1) Use the webbrowser module. import webbrowser webbrowser.open ("www.blendedtechnologies.com") 2) Use os.startfile (or its beefed-up cousin win32api.ShellExecute): import os os.startfile ("http://www.blendedtechnologies.com";) 3) Find out from Windows where the default browser is: (There are alternative ways of doing this, for example querying the registry for AppPaths). import os import tempfile import win32api f = tempfile.TemporaryFile (suffix=".html") hInstance, exe_filename = win32api.FindExecutable (f.name) os.system ("%s %s" % (exe_filename, "www.blendedtechnologies.com")) Hope all that leads you somewhere. Obviously, it doesn't answer the underlying question about double-slashes and quotes and so on, but it seems to meet your current need. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
os.system(cmd) isn't working
Hi guys, I'm trying to run this statement: os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' "www.blendedtechnologies.com"') The goal is to have firefox open to that website. When I type r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' "www.blendedtechnologies.com"' in the python interpreter I get: '"C:\\Program Files\\Mozilla Firefox\\firefox.exe" "www.blendedtechnologies.com"' And when I copy this into my command prompt (less outermost ' ) firefox opens up to that page like I would expect. However in python nothing happens and I get exit status 1. I'm using Python 2.3 on Windows XP pro service pack 2. I'd greatly appriciate any help. Thanks, Greg -- http://mail.python.org/mailman/listinfo/python-list