[geeks] Shell quoting question...

Sridhar Ayengar ploopster at gmail.com
Fri Jul 14 12:15:37 CDT 2006


velociraptor wrote:
> I'm having some trouble with a cron job, I can't figure out how to
> escape it to make it work...
> 
> The script takes an argument that is the name of a profile for use by
> another application.  The sole purpose of my script is to wrap the app
> and generate error mail if the run fails.
> 
> If the profile exists, the directory exists as well, so I am using
> that as a way to ensure there's no errors in the profile name.
> Unfortunately the profiles are generated by a web interface, so a
> space in the profile name is converted to %20 in the directory name.
> The CLI version of the application that processes the profile will
> accept either the space or %20 when you execute the app in an
> interactive terminal.
> 
> In my crontab entry:
> 
> 00 05 * * * /export/home/nmiller/script "profile%20name" > /dev/null 2>&1
> 
> If I issue the above in an interactive shell, it works fine.
> 
> But in the cron log I see this:
> 
> sh /export/home/nmiller/script "profile
> 
> I tried escaping the %, e.g. "profile\%20name", but that just resulted
> in a line in my cron log with my script's exit code for "bad
> argument".
> 
> I suppose I could work around this by doing a transformation in the
> script to check the directory name, but today's my last day, and I
> still have a handful of other things to beat into submission before
> 5:30pm.
> 
> Cluebats appreciated...

Try using single-quotes instead of double.

Peace...  Sridhar



More information about the geeks mailing list