[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Wierd problem with a script that calls nail

Brian wrote:
Kevin Mark wrote:
On Sat, Dec 30, 2006 at 03:48:24PM +0100, brian wrote:
Kevin Mark wrote:
On Sat, Dec 30, 2006 at 01:49:12PM +0100, Brian wrote:
I have a Debian Sarge box and an NSLU2 (Unslung) that I have setup to send me mails when they startup, reboot, and do various other things, they use Nail to sned the emails to me. I tried to setup my mothers PC to do the same, no way I can get it to work. If I run the scripts by hand all works OK. So I have a script /usr/sbin/mailtext.sh, that calls Nail with 2 parameters. In RC.0, RC.3 and RC.5 is have symbolic links to a script in /etc/init.d that calls mailtext.sh.

Mailtext gets called, and I have inserted logger statements in the script, those messages appear in my /var/log/messages, so I know that my script is called when it should be.

But, I never get the mails. If I run the script by hand as root then I get the mail. So I thought maybe something else needs to be started beforehand, but this runs as last in rc.3 amd rc.5, so network is up by then.

Just wondering how to debug this further, how can I get any error messages from nail into my logs? All I tried up till now doesn't seem to work.

Cheers Brian

try adding some logging to the script at the beginning and the end to a
a file.
echo "starting my script" >> mylogfile.log

just FYI here is the script:

set -x
/bin/logger "/opt/sbin/mailtext Sending "$1" to Brian"

echo "$2" | nail -v -s Slug1:"$1"  brian_dorling@t-online.de

That gives plenty of output, just can't figure out a way to capture it yet.

Cheers Brian
echo "$2" | nail -v -s Slug1:"$1" brian_dorling@t-online.de >> mylogfile 2>&1

that did it, pretty basic, I guess I should have been able to figure it out myself. Thanks very much.

Cheers Brian

So, the captured output shows me that nail is not starting at all. My init.d script calls mailtext.sh and both write logger statements that I see in /var/log/messages. During startup and shutdown I see all these messages, but no nail output. If I run any of the scripts, once logged on via ssh as root, then everything runs OK.

Can this be a permissions thing? Under what user do the init scripts run? Nail executable has 755 and root:root.

I am calling nail giving it its full path, so I assume that is not a problem, I would have expected some kind of output if that had been the problem. Hows about nail not boing able to find any .mailrc file?

Cheers Brian

Reply to: