S
S
Sergey2016-08-11 23:07:05
linux
Sergey, 2016-08-11 23:07:05

What is the bash syntax error?

Hello!
Delivered yesterday on Ubuntu Server 16.04 + Apache virtualka.
I downloaded a script for managing hosts from here , but bash swears at everything: a semicolon at the end of a line, empty lines, and in general. Now case
I started looking at everything separately, from the very beginning:
Code for the test:

#!/bin/bash
projects="/home/user/www"
hosts="/etc/apache2/sites-available"
enabled_hosts="/etc/apache2/sites-enabled"
user=$(whoami)
action=$1
name=$2
db=$3
case $action in
add)
echo "Добавить"
;;
del)
echo "Удалить"
;;
*)
echo "Введено неправильное действие"
esac

As a result, I get the message:
6b58b648f1f24cd99b1c3e81a8dac22a.png
What's the matter? Maybe in encoding?
PS: The script was written on Windows, if that says anything

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2016-08-11
@sezavasasilov

Everything works.
edit in Linux, may swear at line breaks

A
Andrey Burov, 2016-08-11
@BuriK666

\r\n hyphens!
dos2unix will help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question