[Tutor] Problem w/ redirect to shell [grabbing URL data with urllib]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 30 Jul 2002 18:33:33 -0700 (PDT)


On Tue, 30 Jul 2002, SA wrote:

> I was tranlating a perl script to python and I was having some problems.
>
> Basically the script takes user input places it in an url string. The
> string is then added to a text of applescript which is then executed as
> follows:
>
> "osascript -l AppleScript -e %s" % todo
>
> Where todo contains the applescript and the rest of the quoted string is
> the command that is executed in the shell. This is a tcsh shell on OSX.
> Basically this translates into something like the following:
>
> Osascript -l AppleScript -e 'tell application Navigator to Get URL
> "www.whatever.com"


HI SA,

I'm not too familiar with Applescript, but if I understand correctly, is
this code trying to retrieve the data associated with some URL?  If so,
would it be possible to use the 'urllib' library?

    http://www.python.org/doc/lib/module-urllib.html

If so, we may want to use urllib just to avoid touching tcsh: I always get
worried because of the tricky features of shell quoting.  Anything that
allows the user enter arbitrary commands needs to be treated carefully if
we're worried about security, and I trust 'urllib' more that tcsh.
*grin*