Results of executing hyperlink in script

Jean-Paul Calderone exarkun at
Thu Jan 29 00:29:08 CET 2009

On Wed, 28 Jan 2009 23:14:59 +0000, MRAB <google at> wrote:
>Muddy Coder wrote:
>>Hi Folks,
>>My previous post got a many helps from the people, and I tested what
>>they suggested. Since this topic maybe needed in future, so I drop
>>these lines below to help the future programmers. The methods worked
>>as below:
>>1. This method was suggested by Cameron Laird:
>>       os.system("start %s" % URL)
>>It works. But, if the URL contains character &, it will fail. For
>>example, if URL has only one field, such as: 
>>this method works well. But, if there more than one field need to be
>>input, such as,
>>the field password failed to reach server, and the CGI script
>You could put quotes around the URL:
>os.startfile('"%s"' % URL)
>os.system('start "%s"' % URL)
>if "&" has a special meaning to the command-line.

What if the URL has a " in it?  Worse, what if the URL is:

    " & rm -rf ~

os.system is a pretty bad thing to use.  Fortunately, the suggestion to
use urllib was a much better one, and you can't use os.system here anyway
since the poster is interested in getting the contents of the page at the


More information about the Python-list mailing list