Ampersands, URL parameters and wget

So there’s this queueing system we wrote for the AJBL, which racks up processor intensive tasks like image crunching to do them in the background. We add commands to a database table as URLs that get called with wget from the app in the background, and it all works remarkably well.

Except this time the command had ampersands in it. It worked every time when you called it directly, but from wget it failed to pick up the second and subsequent params. Just getting to this point took longer than I cared to think about, and because all this happens indirectly in the background, it was a nightmare trying to work out what it thought it was doing. I ended up writing a logger just to be able to find out what it was thinking when executing things in the background like this.

Because the wget command is being executed in the shell on the box in question, the ampersands in the URL are being interpreted by the shell instead of being passed to wget. Simply wrapping the URL in quotes fixes it.

[php]
$cmd = ‘wget "’ . $cmdURL . ‘"’;
[/php]

I don’t actually mind hitting problems like this; the satisfaction when you solve them is great. But it makes estimating projects even more of a joke than it already is, and the loss of momentum is horrifying.

Advertisements

Related

Post navigation

Ian Anderson

I’m a hands-on product person who loves working in startups and agile software teams to help define, design and build great web applications that people find useful and enjoy using. I’ve built several products aimed at online learning and employability, and am keenly interested in “tech for good” and building significant online products for ethical or social businesses.