Need help running external program

Tim Jarman tmj at
Wed Mar 2 23:44:59 CET 2005

Rigga wrote:


> This is the command I am trying to run:
> feed is a list of web addresses
> output, input = popen2("wget -q %s -O - | tr '\r' '\n' | tr \' \" | sed -n
> 's/.*url="\([^"]*\)".*/\1/p'" % feed[counter])
> But it does not work, if I escape the string using r""" and hard code in
> the web address rather than use %s and feed[counter] it works, my question
> is how do I escape the string to get it to work with the %s and
> feed[counter]
> Im new to python as you can tell :-)

Disclaimer: I know nothing about wget beyond what just having typed 'man
wget' told me! ;)

1. What *exactly* does "it does not work" mean? Do you get a traceback? If
so, post it - that will help others to help you. What results are you

2. Are you sure feed contains what you think it contains at this point in
your program? What do you see if you do:

for thing in feed: print thing


A good strategy in these cases is to go in small steps. before you try
getting fancy with popen2, have your program just print the command-line
correctly. Then maybe try it with something like echo just to see that
you're passing what you think you're passing. And so on.

We were all new once - no blame! :)

Website: www DOT jarmania FULLSTOP com

More information about the Python-list mailing list