Unexpected EOF while looking for matching “' – Bash Script

user3106527 asked:

Here is my bash script: http://pastebin.com/9kgGYPmt

Ok so simply, when I run the Bash command I get this error:

I really don’t know why this is happening. Can anyone help? Thanks 🙂

This script is designed to restart the machine and will eventually be called via a Cron job, but this is unrelated and really only to allow ServerFault to post this question.

My answer:

This is a trivial typo.

You have several lines which include:

`echo -ne '\015'\`

I presume you mean to embed a Ctrl-G bell character into the output.

The error is because you have placed an unnecessary backslash before the final backtick, thus escaping it. This isn’t what you want.

Remove it:

`echo -ne '\015'`

Another thing: Get rid of this script entirely.

For starters, you really shouldn’t be rebooting your server via a cron job. If you think you want to, you have another problem, which you should actually find and fix. Any reasonable server should be able to remain up and running for more than a day without intervention.

Second, the shutdown command will happily alert all logged on users (and screen sessions!) automatically. If you really must reboot, try using it to schedule your reboot.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.