> Am 01.04.2022 um 12:23 schrieb SZÉPE Viktor <vik...@szepe.net>:
> 
> Idézem/Quoting Tino Hendricks <t.hendri...@interpool.de>:
> 
>>> Am 01.04.2022 um 09:50 schrieb SZÉPE Viktor <vik...@szepe.net>:
>>> 
>>> Idézem/Quoting Tino Hendricks <t.hendri...@interpool.de 
>>> <mailto:t.hendri...@interpool.de>>:
>>> 
>>>> Dear list,
>>>> 
>>>> I’m trying to monitor an USB port.
>>>> 
>>>> The script „checkUSB.sh“ returns „error“ or „exists“ (successfully tested 
>>>> in Terminal as root).
>>>> 
>>>> Monit runs as root but with
>>>> 
>>>> check program checkUSB with path "/usr/local/sbin/checkUSB.sh"
>>>>   if content != "exists" then alert
>>>> 
>>>> never returns. The process runs forever and is then killed by timeout.
>>> 
>>> Hello Tino!
>>> 
>>> Checks run under the same user as Monit.
>>> You could debug it with
>>> logger $(whoami)
>>> in your script or with monit status command.
>> 
>> Hello Viktor,
>> 
>> thank you so much for your reply!
>> 
>> Monit runs as root, and so does the script (like in my tests).
>> I can see it on my conole:
>> 
>> root     13052  0.0  0.0   1940   384 ?        Ss   10:54   0:00 /bin/sh 
>> /usr/local/sbin/checkUSB.sh
>> root     13055  0.0  0.0   1940    68 ?        S    10:54   0:00 /bin/sh 
>> /usr/local/sbin/checkUSB.sh
>> 
>> Any more ideas?
> 
> As I cannot see what is inside the script it is not possible to help.

I’m sorry, it’s not a secret:

#!/bin/sh
# test for existence and readability of ttyUSB 
logger $(whoami)

PORT=`more /etc/gammu-smsdrc |grep tty|cut -d ' ' -f 3|cut -d '/' -f 3`

RESULT=`ls -l /dev/tty*|grep $PORT`

if [ -z "$RESULT" ]
then
        echo "error"
else
        echo "exists"
fi

exit 0

And now I recognized that using „more“ instead of „cat“ of course is a bad idea 
if not running in an interactive terminal. 🙄

Thank you so much for pushing me into the right direction!

Tino


Reply via email to