[lug] sed from cron job fails (works from command line)

Ben bluey at iguanaworks.net
Tue Oct 23 10:20:22 MDT 2007


Thanks for everyone's suggestions. Let me especially thank Rob Nagler 
for rewriting my script and providing a solution.

So here's a list of what didn't work:

calling /etc/skel/.bashrc or /root/.bashrc or .bash_profile inside the 
script

changing #!/bin/sh to $!/bin/bash -- didn't make a difference

change the shell in /etc/crontab to SHELL=/bin/bash

Unfortunately,  I was never able to get my script to fail on the command 
line.

But Rob rewrite my little script into perl where it doesn't have all 
this escape characters and the like, and that worked like a charm. The 
sed line (that was the problem) turned into:

print(grep(
    s/.*RCPT from ([a-zA-Z0-9\.-]*)\[([0-9.]*)\]: (.*;).*from=<(.*)> to=<(.*)> proto.*helo=<(.*)>.*/$1\t$2\t$4\t$5\t$6\t$3/,
    <IN>,
));


in a perl script. Now I just have my bash script (that does other stuff 
as well) call the perl script instead of doing that silly sed stuff. So, 
I don't know why the sed stuff didn't work in the first place, but right 
now I've got everything working, so I think I'm done. Maybe I'll try to 
track down the cron/sed problem at point in the future.

Thanks to everyone, but particularity  Rob for all the help,

Ben




More information about the LUG mailing list