0

I have a simple bash script:

#!/bin/bash
wget -q 'http://requestb.in/1fq0r3s1?foo=a%2Bb' -O /dev/null

If I run this from the commandline and then inspect at http://requestb.in/1fq0r3s1?inspect I see

Query String
foo: a+b

Which is what I would expect.

However when the bash script is run by CRON, I see

Query String
foo: a b

It looks like something has decoded the URL before sending, converting the %2B into + which is then interpreted as a space by the receiving server.

Can anyone explain this and help me figure out how to get the script to behave in cron as it does when run from the command line?

(Note: curl does not suffer this same behaviour, but I'm interested in learning why wget behaves this way)

artfulrobot
  • 2,949
  • 13
  • 36
  • 60

1 Answers1

0

%(percent) means a new line in cron!

So you either have to escape it like this foo=a\%2Bb or put your command in a bash file and run that file in crontab.

Arash
  • 284
  • 1
  • 8
  • I know % is special in cron entries but this is in an external bash script; there is no % in the crontab. And if I change it to curl then the problem is gone. – artfulrobot Jul 04 '16 at 21:50