siz
siz

Reputation: 117

.sh unexpected "fi (expected "then")

I have some trouble getting my .sh script working. I get the following error message:

power_toggle.sh: line 8: syntax error: unexpected "fi" (expecting "then")

The script:

#!/bin/sh
SERVICE='hyperiond'
if pgrep $SERVICE > /dev/null
then
    killall hyperiond 2>/dev/null
else
    /storage/.config/autostart.sh > /dev/null 2>&1 &
fi

I have tried shellcheck.net, and it doesn't find anything wrong with it.. I have also chmod +x'ed it. The 2 commands work fine running them via a ssh terminal.

Hope u guys can help, because I am lost.

Upvotes: 1

Views: 1413

Answers (1)

nwk
nwk

Reputation: 4050

Convert your line endings from Windows to Unix (LF only).

Upvotes: 4

Related Questions