What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

syntax error: unexpected "done" (expecting "then")

jpdsc

Regular Contributor
Hi there,

I am trying to use the script here:
https://github.com/RMerl/asuswrt-merlin/wiki/WOL-Script-Wake-Up-Your-Webserver-On-Internet-Traffic

Everything has been filled in but it does not seem to be working.
I tried running wake.sh manually but get below error:
Code:
: not foundts/wake.sh: line 2:
: not foundts/wake.sh: line 12:
/jffs/scripts/wake.sh: line 29: syntax error: unexpected "done" (expecting "then")

The code I am using:
Code:
#!/bin/sh

INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.100
PORT=80
IFACE=br0
MAC=MYMAC
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/ether-wake.log"

while sleep $INTERVAL;do
NEW=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print }' | tail -1`
SRC=`echo $NEW | awk -F'[=| ]' '{print $8}'`
DPORT=`echo $NEW | awk -F'[=| ]' '{print $27}'`
PROTO=`echo $NEW | awk -F'[=| ]' '{print $23}'`

if [ "$NEW" != "" -a "$NEW" != "$OLD" ]; then
if ! ping -qc $NUMP $TARGET >/dev/null; then
# echo "NOWAKE $TARGET was accessed by $SRC, port $DPORT, protocol $PROTO and is already alive at" `date`>> $LOGFILE
# else
echo "WAKE $TARGET requested by $SRC, port $DPORT, protocol $PROTO at" `date`>> $LOGFILE
$WOL -i $IFACE $MAC
sleep 5
fi
OLD=$NEW
fi
done

Is the script outdated?

Thanks.
 
It's probably caused because you have used a Windows-type editor (i.e. notepad) to create the file.

Log on to the router and type the following and try again.

dos2unix /jffs/scripts/wake.sh
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top