Need help running external program
Tim Jarman
tmj at SPAMLESSjarmania.com
Sun Feb 27 13:55:13 EST 2005
Rigga wrote:
> Pink wrote:
>
>> 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.
>
> Hi,
>
> Thanks for replying however I have just tried that and it does not seem to
> work, it doesnt return any results (i take it the r was a typo)
>
> Thanks
>
> RiGGa
No, the r was the point - it's there to tell Python not to do any escaping
on the string. Try it again with the r and see what happens.
--
Website: www DOT jarmania FULLSTOP com
More information about the Python-list
mailing list