Bash erro when finishing with EOF












0















I apologize in advance if the message do not seem appropriate here but i believe it is the good place.



I got this strange error when i execute my bash script:



./cluster_bootstrap.sh 
./cluster_bootstrap.sh: line 15: $'r': command not found
./cluster_bootstrap.sh: line 91: warning: here-document at line 37 delimited by end-of-file (wanted `EOF')
./cluster_bootstrap.sh: line 92: syntax error: unexpected end of file


Meanwhile everything seems correct when i copy paste the script in my shell.
Any idea of this odd behaviour ?



PS: Here is my script:



address=192.168.1.101
# DNS (Celui du FAI est: 80.10.246.130 ; tandis que celui de google est 8.8.8.8)
nameserver=8.8.8.8
#Hostname
hostname=slave1
#Hosts
hostname_master=master
address_master=192.168.1.100
hostname_slave1=slave1
address_slave1=192.168.1.101
hostname_slave2=slave2
address_slave2=192.168.1.102
#__I) ________ Configuration d'une ip statique pour le bridge Network__________
#0) Install ifupdown et resolvconf
if [ -z `which resolvconf` ]
then
echo "sudo apt install resolvconf is required"
sudo apt install resolvconf
else
echo "resolvconf is already installed!"
fi

if [ -z `which ifup` ]
then
echo "sudo apt install ifupdown is required"
sudo apt install resolvconf
else
echo "ifupdown is already installed!"
echo "Super!"
fi


#1) Configurer l'adresse statique
#cat << EOF | sudo tee /etc/network/interfaces
sudo tee /etc/network/interfaces << EOF
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
address $address
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
EOF

sudo ifup enp0s3

#2) Configurer le DNS

sudo tee /etc/resolvconf/resolv.conf.d/tail << EOF
nameserver $nameserver
EOF

#3)
#sudo reboot

#__II) ________ Configuration de clés ssh_________

#1) hostname
echo "hostname=$hostname"
echo "$hostname " | sudo tee /etc/hostname

#2) hosts
sudo tee /etc/hosts << EOF
127.0.0.1 localhost
$address_master $hostname_master
$address_slave1 $hostname_slave1
$address_slave2 $hostname_slave2

EOF









share|improve this question


















  • 1





    Have you transfer this script from Windows machine? Have you try to use dos2unix?

    – Romeo Ninov
    Feb 14 at 14:02






  • 1





    Perhaps i did some copy paste beween my windows host and my linux guest. I don't know dos2unix but i can check. anyway isn't it odd that a copy paste in terminal doesn't return the same result that executing bash my_script ? Thanks

    – Pincemaille Laurent
    Feb 14 at 15:37











  • @PincemailleLaurent Copying and pasting a printed file will remove nonprinting characters like carriage return, which is probably what's causing the problem. See Are shell scripts sensitive to encoding and line endings?

    – Gordon Davisson
    Feb 14 at 19:47











  • Thank you to both of you! dos2unix worked perfectly! Cheers.

    – Pincemaille Laurent
    Feb 15 at 18:47
















0















I apologize in advance if the message do not seem appropriate here but i believe it is the good place.



I got this strange error when i execute my bash script:



./cluster_bootstrap.sh 
./cluster_bootstrap.sh: line 15: $'r': command not found
./cluster_bootstrap.sh: line 91: warning: here-document at line 37 delimited by end-of-file (wanted `EOF')
./cluster_bootstrap.sh: line 92: syntax error: unexpected end of file


Meanwhile everything seems correct when i copy paste the script in my shell.
Any idea of this odd behaviour ?



PS: Here is my script:



address=192.168.1.101
# DNS (Celui du FAI est: 80.10.246.130 ; tandis que celui de google est 8.8.8.8)
nameserver=8.8.8.8
#Hostname
hostname=slave1
#Hosts
hostname_master=master
address_master=192.168.1.100
hostname_slave1=slave1
address_slave1=192.168.1.101
hostname_slave2=slave2
address_slave2=192.168.1.102
#__I) ________ Configuration d'une ip statique pour le bridge Network__________
#0) Install ifupdown et resolvconf
if [ -z `which resolvconf` ]
then
echo "sudo apt install resolvconf is required"
sudo apt install resolvconf
else
echo "resolvconf is already installed!"
fi

if [ -z `which ifup` ]
then
echo "sudo apt install ifupdown is required"
sudo apt install resolvconf
else
echo "ifupdown is already installed!"
echo "Super!"
fi


#1) Configurer l'adresse statique
#cat << EOF | sudo tee /etc/network/interfaces
sudo tee /etc/network/interfaces << EOF
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
address $address
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
EOF

sudo ifup enp0s3

#2) Configurer le DNS

sudo tee /etc/resolvconf/resolv.conf.d/tail << EOF
nameserver $nameserver
EOF

#3)
#sudo reboot

#__II) ________ Configuration de clés ssh_________

#1) hostname
echo "hostname=$hostname"
echo "$hostname " | sudo tee /etc/hostname

#2) hosts
sudo tee /etc/hosts << EOF
127.0.0.1 localhost
$address_master $hostname_master
$address_slave1 $hostname_slave1
$address_slave2 $hostname_slave2

EOF









share|improve this question


















  • 1





    Have you transfer this script from Windows machine? Have you try to use dos2unix?

    – Romeo Ninov
    Feb 14 at 14:02






  • 1





    Perhaps i did some copy paste beween my windows host and my linux guest. I don't know dos2unix but i can check. anyway isn't it odd that a copy paste in terminal doesn't return the same result that executing bash my_script ? Thanks

    – Pincemaille Laurent
    Feb 14 at 15:37











  • @PincemailleLaurent Copying and pasting a printed file will remove nonprinting characters like carriage return, which is probably what's causing the problem. See Are shell scripts sensitive to encoding and line endings?

    – Gordon Davisson
    Feb 14 at 19:47











  • Thank you to both of you! dos2unix worked perfectly! Cheers.

    – Pincemaille Laurent
    Feb 15 at 18:47














0












0








0








I apologize in advance if the message do not seem appropriate here but i believe it is the good place.



I got this strange error when i execute my bash script:



./cluster_bootstrap.sh 
./cluster_bootstrap.sh: line 15: $'r': command not found
./cluster_bootstrap.sh: line 91: warning: here-document at line 37 delimited by end-of-file (wanted `EOF')
./cluster_bootstrap.sh: line 92: syntax error: unexpected end of file


Meanwhile everything seems correct when i copy paste the script in my shell.
Any idea of this odd behaviour ?



PS: Here is my script:



address=192.168.1.101
# DNS (Celui du FAI est: 80.10.246.130 ; tandis que celui de google est 8.8.8.8)
nameserver=8.8.8.8
#Hostname
hostname=slave1
#Hosts
hostname_master=master
address_master=192.168.1.100
hostname_slave1=slave1
address_slave1=192.168.1.101
hostname_slave2=slave2
address_slave2=192.168.1.102
#__I) ________ Configuration d'une ip statique pour le bridge Network__________
#0) Install ifupdown et resolvconf
if [ -z `which resolvconf` ]
then
echo "sudo apt install resolvconf is required"
sudo apt install resolvconf
else
echo "resolvconf is already installed!"
fi

if [ -z `which ifup` ]
then
echo "sudo apt install ifupdown is required"
sudo apt install resolvconf
else
echo "ifupdown is already installed!"
echo "Super!"
fi


#1) Configurer l'adresse statique
#cat << EOF | sudo tee /etc/network/interfaces
sudo tee /etc/network/interfaces << EOF
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
address $address
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
EOF

sudo ifup enp0s3

#2) Configurer le DNS

sudo tee /etc/resolvconf/resolv.conf.d/tail << EOF
nameserver $nameserver
EOF

#3)
#sudo reboot

#__II) ________ Configuration de clés ssh_________

#1) hostname
echo "hostname=$hostname"
echo "$hostname " | sudo tee /etc/hostname

#2) hosts
sudo tee /etc/hosts << EOF
127.0.0.1 localhost
$address_master $hostname_master
$address_slave1 $hostname_slave1
$address_slave2 $hostname_slave2

EOF









share|improve this question














I apologize in advance if the message do not seem appropriate here but i believe it is the good place.



I got this strange error when i execute my bash script:



./cluster_bootstrap.sh 
./cluster_bootstrap.sh: line 15: $'r': command not found
./cluster_bootstrap.sh: line 91: warning: here-document at line 37 delimited by end-of-file (wanted `EOF')
./cluster_bootstrap.sh: line 92: syntax error: unexpected end of file


Meanwhile everything seems correct when i copy paste the script in my shell.
Any idea of this odd behaviour ?



PS: Here is my script:



address=192.168.1.101
# DNS (Celui du FAI est: 80.10.246.130 ; tandis que celui de google est 8.8.8.8)
nameserver=8.8.8.8
#Hostname
hostname=slave1
#Hosts
hostname_master=master
address_master=192.168.1.100
hostname_slave1=slave1
address_slave1=192.168.1.101
hostname_slave2=slave2
address_slave2=192.168.1.102
#__I) ________ Configuration d'une ip statique pour le bridge Network__________
#0) Install ifupdown et resolvconf
if [ -z `which resolvconf` ]
then
echo "sudo apt install resolvconf is required"
sudo apt install resolvconf
else
echo "resolvconf is already installed!"
fi

if [ -z `which ifup` ]
then
echo "sudo apt install ifupdown is required"
sudo apt install resolvconf
else
echo "ifupdown is already installed!"
echo "Super!"
fi


#1) Configurer l'adresse statique
#cat << EOF | sudo tee /etc/network/interfaces
sudo tee /etc/network/interfaces << EOF
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
address $address
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
EOF

sudo ifup enp0s3

#2) Configurer le DNS

sudo tee /etc/resolvconf/resolv.conf.d/tail << EOF
nameserver $nameserver
EOF

#3)
#sudo reboot

#__II) ________ Configuration de clés ssh_________

#1) hostname
echo "hostname=$hostname"
echo "$hostname " | sudo tee /etc/hostname

#2) hosts
sudo tee /etc/hosts << EOF
127.0.0.1 localhost
$address_master $hostname_master
$address_slave1 $hostname_slave1
$address_slave2 $hostname_slave2

EOF






ubuntu bash






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 14 at 13:53









Pincemaille LaurentPincemaille Laurent

11




11








  • 1





    Have you transfer this script from Windows machine? Have you try to use dos2unix?

    – Romeo Ninov
    Feb 14 at 14:02






  • 1





    Perhaps i did some copy paste beween my windows host and my linux guest. I don't know dos2unix but i can check. anyway isn't it odd that a copy paste in terminal doesn't return the same result that executing bash my_script ? Thanks

    – Pincemaille Laurent
    Feb 14 at 15:37











  • @PincemailleLaurent Copying and pasting a printed file will remove nonprinting characters like carriage return, which is probably what's causing the problem. See Are shell scripts sensitive to encoding and line endings?

    – Gordon Davisson
    Feb 14 at 19:47











  • Thank you to both of you! dos2unix worked perfectly! Cheers.

    – Pincemaille Laurent
    Feb 15 at 18:47














  • 1





    Have you transfer this script from Windows machine? Have you try to use dos2unix?

    – Romeo Ninov
    Feb 14 at 14:02






  • 1





    Perhaps i did some copy paste beween my windows host and my linux guest. I don't know dos2unix but i can check. anyway isn't it odd that a copy paste in terminal doesn't return the same result that executing bash my_script ? Thanks

    – Pincemaille Laurent
    Feb 14 at 15:37











  • @PincemailleLaurent Copying and pasting a printed file will remove nonprinting characters like carriage return, which is probably what's causing the problem. See Are shell scripts sensitive to encoding and line endings?

    – Gordon Davisson
    Feb 14 at 19:47











  • Thank you to both of you! dos2unix worked perfectly! Cheers.

    – Pincemaille Laurent
    Feb 15 at 18:47








1




1





Have you transfer this script from Windows machine? Have you try to use dos2unix?

– Romeo Ninov
Feb 14 at 14:02





Have you transfer this script from Windows machine? Have you try to use dos2unix?

– Romeo Ninov
Feb 14 at 14:02




1




1





Perhaps i did some copy paste beween my windows host and my linux guest. I don't know dos2unix but i can check. anyway isn't it odd that a copy paste in terminal doesn't return the same result that executing bash my_script ? Thanks

– Pincemaille Laurent
Feb 14 at 15:37





Perhaps i did some copy paste beween my windows host and my linux guest. I don't know dos2unix but i can check. anyway isn't it odd that a copy paste in terminal doesn't return the same result that executing bash my_script ? Thanks

– Pincemaille Laurent
Feb 14 at 15:37













@PincemailleLaurent Copying and pasting a printed file will remove nonprinting characters like carriage return, which is probably what's causing the problem. See Are shell scripts sensitive to encoding and line endings?

– Gordon Davisson
Feb 14 at 19:47





@PincemailleLaurent Copying and pasting a printed file will remove nonprinting characters like carriage return, which is probably what's causing the problem. See Are shell scripts sensitive to encoding and line endings?

– Gordon Davisson
Feb 14 at 19:47













Thank you to both of you! dos2unix worked perfectly! Cheers.

– Pincemaille Laurent
Feb 15 at 18:47





Thank you to both of you! dos2unix worked perfectly! Cheers.

– Pincemaille Laurent
Feb 15 at 18:47










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1405704%2fbash-erro-when-finishing-with-eof%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1405704%2fbash-erro-when-finishing-with-eof%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕