monit-general
[Top][All Lists]
Advanced

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

Re: How to run bash script?


From: Werner Flamme
Subject: Re: How to run bash script?
Date: Sat, 22 Mar 2014 16:57:50 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

[20.03.2014 23:17] [Martin Vaner]:
> Hi Martin,
> 
> address@hidden:/usr/local/bin# ls -l /bin/bash
> -rwxr-xr-x 1 root root 975488 Dec 30  2012 /bin/bash
> address@hidden:/usr/local/bin#
> 
> It is exit. So, when i run the script from the console, i just getting 
> this output:
> 
> address@hidden:/mnt/vouchers# bash -x logtest.sh
> ++ tail -n 10 contego.log
> ++ grep Error
> ++ wc -l
> + errorcount=0
> + '[' 0 -gt 0 ']'
> + echo 0
> 0
> + exit 0
> address@hidden:/mnt/vouchers#
> 
> If i run the script form the console directly, it is working fine.

Often that's a sign that the PATH environment variable is not set
correctly. Try inserting

PATH=/bin:/usr/bin:/sbin:/usr/sbin

as second line in the file. And/Or use absolute paths to the commands in
the script, like

errorcount=$(/usr/bin/tail -n 10  /mnt/vouchers/contego.log | \
 /usr/bin/grep -c Error)

to get the number of 'Error' lines. The line break is due to the line
length and my MUA ;-)

HTH, Werner
-- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]