Need help running external program
Pink
pink at odahoda.de
Sun Feb 27 12:17:30 EST 2005
Rigga wrote:
> Hi,
>
> I am running the line of code below from a shell script and it works fine,
> however I am at a total loss on how i can run it from within a Python
> script as every option I have tried fails and it appears to be down to the
> escaping of certain characters.
>
> wget -q www.anywebpage.com -O - | tr '\r' '\n' | tr \' \" | sed -n
> 's/.*url="\([^"]*\)".*/\1/p'
If your problem is getting a python string without worrying about how to
escape the escape sequences, try:
r"""wget -q www.anywebpage.com -O - | tr '\r' '\n' | tr \' \" | sed -n
's/.*url="\([^"]*\)".*/\1/p'"""
You should be able to pass this directly to a popen() function.
More information about the Python-list
mailing list