shell script error : Syntax error: â(â unexpected
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have checked the previous post on this error. still did not get the solution working. Here is my bash script. can some one help me figure out the issue . I have used https://www.shellcheck.net/ to see any error. I did not find any.
Error:
Dockerfunctiontest.sh: 2: Dockerfunctiontest.sh: Syntax error: "(" unexpected
script:
#!/bin/bash
function BuildSimpleContainer ()
docker search mariadb
docker pull mariadb:latest
docker run --name mariadbtestfour -e MYSQL_ROOT_PASSWORD=mypass -d mariadb --log-bin --binlog-format=MIXED
docker exec -it mariadbtest bash
apt-get -qq update
apt-get -qq -y install curl
apt-get -qq -y install wget
apt-get update
apt-get install apt-transport-https
apt-get update
cd /home
mkdir mdsd
cd mdsd/
wget '<blob url to pfx file>'
echo "certififcate Downloaded"
wget '<blob url file1>'
echo "file1 Downloaded"
wget 'blob url file2'
echo "file2 Downloaded"
BuildSimpleContainer
bash shell-script shell syntax
add a comment |Â
up vote
0
down vote
favorite
I have checked the previous post on this error. still did not get the solution working. Here is my bash script. can some one help me figure out the issue . I have used https://www.shellcheck.net/ to see any error. I did not find any.
Error:
Dockerfunctiontest.sh: 2: Dockerfunctiontest.sh: Syntax error: "(" unexpected
script:
#!/bin/bash
function BuildSimpleContainer ()
docker search mariadb
docker pull mariadb:latest
docker run --name mariadbtestfour -e MYSQL_ROOT_PASSWORD=mypass -d mariadb --log-bin --binlog-format=MIXED
docker exec -it mariadbtest bash
apt-get -qq update
apt-get -qq -y install curl
apt-get -qq -y install wget
apt-get update
apt-get install apt-transport-https
apt-get update
cd /home
mkdir mdsd
cd mdsd/
wget '<blob url to pfx file>'
echo "certififcate Downloaded"
wget '<blob url file1>'
echo "file1 Downloaded"
wget 'blob url file2'
echo "file2 Downloaded"
BuildSimpleContainer
bash shell-script shell syntax
The error message is pretty self-explanatory: the(
shouldn't be there on line 2.
â devius
Feb 26 at 19:31
2
How do you call this script?
â Tomasz
Feb 26 at 19:34
1
@tomasz has hit it right on the nose. The script is being executed bysh
, notbash
, and is choking on the function declaration syntax.
â DopeGhoti
Feb 26 at 19:38
Related: difference between "function foo() " and "foo() "
â Stéphane Chazelas
Feb 26 at 20:53
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have checked the previous post on this error. still did not get the solution working. Here is my bash script. can some one help me figure out the issue . I have used https://www.shellcheck.net/ to see any error. I did not find any.
Error:
Dockerfunctiontest.sh: 2: Dockerfunctiontest.sh: Syntax error: "(" unexpected
script:
#!/bin/bash
function BuildSimpleContainer ()
docker search mariadb
docker pull mariadb:latest
docker run --name mariadbtestfour -e MYSQL_ROOT_PASSWORD=mypass -d mariadb --log-bin --binlog-format=MIXED
docker exec -it mariadbtest bash
apt-get -qq update
apt-get -qq -y install curl
apt-get -qq -y install wget
apt-get update
apt-get install apt-transport-https
apt-get update
cd /home
mkdir mdsd
cd mdsd/
wget '<blob url to pfx file>'
echo "certififcate Downloaded"
wget '<blob url file1>'
echo "file1 Downloaded"
wget 'blob url file2'
echo "file2 Downloaded"
BuildSimpleContainer
bash shell-script shell syntax
I have checked the previous post on this error. still did not get the solution working. Here is my bash script. can some one help me figure out the issue . I have used https://www.shellcheck.net/ to see any error. I did not find any.
Error:
Dockerfunctiontest.sh: 2: Dockerfunctiontest.sh: Syntax error: "(" unexpected
script:
#!/bin/bash
function BuildSimpleContainer ()
docker search mariadb
docker pull mariadb:latest
docker run --name mariadbtestfour -e MYSQL_ROOT_PASSWORD=mypass -d mariadb --log-bin --binlog-format=MIXED
docker exec -it mariadbtest bash
apt-get -qq update
apt-get -qq -y install curl
apt-get -qq -y install wget
apt-get update
apt-get install apt-transport-https
apt-get update
cd /home
mkdir mdsd
cd mdsd/
wget '<blob url to pfx file>'
echo "certififcate Downloaded"
wget '<blob url file1>'
echo "file1 Downloaded"
wget 'blob url file2'
echo "file2 Downloaded"
BuildSimpleContainer
bash shell-script shell syntax
edited Feb 26 at 20:21
Tomasz
8,04052560
8,04052560
asked Feb 26 at 19:24
Bobby
122
122
The error message is pretty self-explanatory: the(
shouldn't be there on line 2.
â devius
Feb 26 at 19:31
2
How do you call this script?
â Tomasz
Feb 26 at 19:34
1
@tomasz has hit it right on the nose. The script is being executed bysh
, notbash
, and is choking on the function declaration syntax.
â DopeGhoti
Feb 26 at 19:38
Related: difference between "function foo() " and "foo() "
â Stéphane Chazelas
Feb 26 at 20:53
add a comment |Â
The error message is pretty self-explanatory: the(
shouldn't be there on line 2.
â devius
Feb 26 at 19:31
2
How do you call this script?
â Tomasz
Feb 26 at 19:34
1
@tomasz has hit it right on the nose. The script is being executed bysh
, notbash
, and is choking on the function declaration syntax.
â DopeGhoti
Feb 26 at 19:38
Related: difference between "function foo() " and "foo() "
â Stéphane Chazelas
Feb 26 at 20:53
The error message is pretty self-explanatory: the
(
shouldn't be there on line 2.â devius
Feb 26 at 19:31
The error message is pretty self-explanatory: the
(
shouldn't be there on line 2.â devius
Feb 26 at 19:31
2
2
How do you call this script?
â Tomasz
Feb 26 at 19:34
How do you call this script?
â Tomasz
Feb 26 at 19:34
1
1
@tomasz has hit it right on the nose. The script is being executed by
sh
, not bash
, and is choking on the function declaration syntax.â DopeGhoti
Feb 26 at 19:38
@tomasz has hit it right on the nose. The script is being executed by
sh
, not bash
, and is choking on the function declaration syntax.â DopeGhoti
Feb 26 at 19:38
Related: difference between "function foo() " and "foo() "
â Stéphane Chazelas
Feb 26 at 20:53
Related: difference between "function foo() " and "foo() "
â Stéphane Chazelas
Feb 26 at 20:53
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
My guess is that you don't run this script as a Bash script, but with some other shell, which doesn't accept this syntax. Eg. sh
.
As you can see in Shellcheck, and as Bash's man
on my Debian confirms, this syntax is correct:
name () compound-command [redirection]
function name [()] compound-command [redirection]
You are using the second one from the two above, and your compound-command
is the contents of the ...
braces. And that's fine as far as man bash
goes. But then, there are voices against this construct, as in the link in John Moon's comment below the other answer. And in the link to Greg's Wiki in that answer again.
Going back to your question, taking into consideration the name of the script, namely Dockerfunctiontest.sh
, I might think you don't see much difference between sh
and bash
. Probably you run the script with this command:
sh Dockerfunctiontest.sh
While it would be reasonable to run it with either:
bash Dockerfunctiontest.sh
or
./Dockerfunctiontest.sh
The last one picks the interpreter basing on the first line in the script, namely:
#!/bin/bash
And while the interpreter named in the script is Bash, why not name the file the proper way?
Dockerfunctiontest.bash
Less confusion in the future.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
My guess is that you don't run this script as a Bash script, but with some other shell, which doesn't accept this syntax. Eg. sh
.
As you can see in Shellcheck, and as Bash's man
on my Debian confirms, this syntax is correct:
name () compound-command [redirection]
function name [()] compound-command [redirection]
You are using the second one from the two above, and your compound-command
is the contents of the ...
braces. And that's fine as far as man bash
goes. But then, there are voices against this construct, as in the link in John Moon's comment below the other answer. And in the link to Greg's Wiki in that answer again.
Going back to your question, taking into consideration the name of the script, namely Dockerfunctiontest.sh
, I might think you don't see much difference between sh
and bash
. Probably you run the script with this command:
sh Dockerfunctiontest.sh
While it would be reasonable to run it with either:
bash Dockerfunctiontest.sh
or
./Dockerfunctiontest.sh
The last one picks the interpreter basing on the first line in the script, namely:
#!/bin/bash
And while the interpreter named in the script is Bash, why not name the file the proper way?
Dockerfunctiontest.bash
Less confusion in the future.
add a comment |Â
up vote
4
down vote
My guess is that you don't run this script as a Bash script, but with some other shell, which doesn't accept this syntax. Eg. sh
.
As you can see in Shellcheck, and as Bash's man
on my Debian confirms, this syntax is correct:
name () compound-command [redirection]
function name [()] compound-command [redirection]
You are using the second one from the two above, and your compound-command
is the contents of the ...
braces. And that's fine as far as man bash
goes. But then, there are voices against this construct, as in the link in John Moon's comment below the other answer. And in the link to Greg's Wiki in that answer again.
Going back to your question, taking into consideration the name of the script, namely Dockerfunctiontest.sh
, I might think you don't see much difference between sh
and bash
. Probably you run the script with this command:
sh Dockerfunctiontest.sh
While it would be reasonable to run it with either:
bash Dockerfunctiontest.sh
or
./Dockerfunctiontest.sh
The last one picks the interpreter basing on the first line in the script, namely:
#!/bin/bash
And while the interpreter named in the script is Bash, why not name the file the proper way?
Dockerfunctiontest.bash
Less confusion in the future.
add a comment |Â
up vote
4
down vote
up vote
4
down vote
My guess is that you don't run this script as a Bash script, but with some other shell, which doesn't accept this syntax. Eg. sh
.
As you can see in Shellcheck, and as Bash's man
on my Debian confirms, this syntax is correct:
name () compound-command [redirection]
function name [()] compound-command [redirection]
You are using the second one from the two above, and your compound-command
is the contents of the ...
braces. And that's fine as far as man bash
goes. But then, there are voices against this construct, as in the link in John Moon's comment below the other answer. And in the link to Greg's Wiki in that answer again.
Going back to your question, taking into consideration the name of the script, namely Dockerfunctiontest.sh
, I might think you don't see much difference between sh
and bash
. Probably you run the script with this command:
sh Dockerfunctiontest.sh
While it would be reasonable to run it with either:
bash Dockerfunctiontest.sh
or
./Dockerfunctiontest.sh
The last one picks the interpreter basing on the first line in the script, namely:
#!/bin/bash
And while the interpreter named in the script is Bash, why not name the file the proper way?
Dockerfunctiontest.bash
Less confusion in the future.
My guess is that you don't run this script as a Bash script, but with some other shell, which doesn't accept this syntax. Eg. sh
.
As you can see in Shellcheck, and as Bash's man
on my Debian confirms, this syntax is correct:
name () compound-command [redirection]
function name [()] compound-command [redirection]
You are using the second one from the two above, and your compound-command
is the contents of the ...
braces. And that's fine as far as man bash
goes. But then, there are voices against this construct, as in the link in John Moon's comment below the other answer. And in the link to Greg's Wiki in that answer again.
Going back to your question, taking into consideration the name of the script, namely Dockerfunctiontest.sh
, I might think you don't see much difference between sh
and bash
. Probably you run the script with this command:
sh Dockerfunctiontest.sh
While it would be reasonable to run it with either:
bash Dockerfunctiontest.sh
or
./Dockerfunctiontest.sh
The last one picks the interpreter basing on the first line in the script, namely:
#!/bin/bash
And while the interpreter named in the script is Bash, why not name the file the proper way?
Dockerfunctiontest.bash
Less confusion in the future.
answered Feb 26 at 20:13
Tomasz
8,04052560
8,04052560
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426778%2fshell-script-error-syntax-error-unexpected%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
The error message is pretty self-explanatory: the
(
shouldn't be there on line 2.â devius
Feb 26 at 19:31
2
How do you call this script?
â Tomasz
Feb 26 at 19:34
1
@tomasz has hit it right on the nose. The script is being executed by
sh
, notbash
, and is choking on the function declaration syntax.â DopeGhoti
Feb 26 at 19:38
Related: difference between "function foo() " and "foo() "
â Stéphane Chazelas
Feb 26 at 20:53