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 -- http://mail.python.org/mailman/listinfo/python-list