You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to notify the reboot of a raspberry pi to another server using wscat.
I wrote this script:
#!/bin/sh
date >> reboot.log
cmd="wscat -n -x reboot -c wss://xxxxxxxxxxxxxxxx.com:18800/sub"
OUTPUT=$($cmd)
echo $OUTPUT
while [ $OUTPUT != "ok" ]; do
sleep 30
OUTPUT=$($cmd)
done
--> it works well from command line with and without sudo. The server returns "ok" and the script stops before entering the loop.
-->When launched from this cronjob : @reboot /home/pi/xxxxxxxx/rebootNotify.sh
Nothing is returned from the wscat command, the script enters infinitly the loop (The loop exists in case
unavailable network at reboot time. BTW, adding a sleep in the cron before calling the scripts leads to the same
result).
Where is the bug?
note : wscat has been installed using sudo npm install -g wscat.
Thanks
Julien
The text was updated successfully, but these errors were encountered:
I don't know, if the script works when run manually it should also work when run as a cron job. Check if the server receives the message. If you don't control it use another one.
Also check the crontab PATH. It is possible that wscat is not found.
Thanks for your answer.
I'm sure that server receives nothing and even not a connection attempt.
I echoed the path variable in the script.
Called from my own session, path is
/usr/local/sbin:/usr/local/bin/:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/snap/bin
Called from crontab:
/usr/local/sbin:/usr/local/bin/:/usr/sbin:/usr/bin:/sbin:/bin
I don't see any significative difference.
I also added "which wscat" command that returns in both case the correct path...
I can confirm this behaviour.
Run from bash
/usr/local/bin/wscat -x . -c wss://example.com > /tmp/output.txt
writes the output to output.txt as expected while run from cron
*/1 * * * * /usr/local/bin/wscat -x . -c wss://example.com > /tmp/output.txt
only creates an empty file
Hello,
I want to notify the reboot of a raspberry pi to another server using wscat.
I wrote this script:
--> it works well from command line with and without sudo. The server returns "ok" and the script stops before entering the loop.
-->When launched from this cronjob :
@reboot /home/pi/xxxxxxxx/rebootNotify.sh
Nothing is returned from the wscat command, the script enters infinitly the loop (The loop exists in case
unavailable network at reboot time. BTW, adding a sleep in the cron before calling the scripts leads to the same
result).
Where is the bug?
note : wscat has been installed using sudo npm install -g wscat.
Thanks
Julien
The text was updated successfully, but these errors were encountered: