Erro de sintaxe [RESOLVIDO]

1. Erro de sintaxe [RESOLVIDO]

Wellington Luiz de Almeida Junior
Wellingtonty

(usa Debian)

Enviado em 22/10/2016 - 16:41h

Meu script esta dando erro na line 78 mas não tenho ideia do que possa ser, segue um pedaço do script

75 apt-get install zip unzip
76 unzip moodle-latest-31.zip
77 0)
78 echo "Saindo..."
79 exit;;

(Os números indicam a linha do comando)

Minha primeira vez aqui no forum, caso esteja erra me digam por favor


  


2. MELHOR RESPOSTA

Perfil removido
removido

(usa Nenhuma)

Enviado em 22/10/2016 - 17:42h

5) 
apt-get update
apt-get upgrade
apt-get install apache2 mysql-server php5-mysql
mysql_install_db
mysql_secure_installation
apt-get install php5 libapache2-mod-php5 php5-mcrypt
rm /etc/apache2/mods-enabled/dir.conf
echo "<IfModule mod_dir.c>" >> /etc/apache2/mods-enabled/dir.conf
echo DirectoryIndex index.php index.cgi index.pl index.html index.xhtml index.htm /etc/apache2/mods-enabled/dir.conf >> /etc/apache2/mods-enabled/dir.conf
echo "</IfModule>" >> /etc/apache2/mods-enabled/dir.conf
service apache2 restart
mkdir /Moodle
chmod 777 /Moodle
cd /var/www/html/
wget https://download.moodle.org/download.php/stable31/moodle-latest-31.zip
apt-get install zip unzip
unzip moodle-latest-31.zip


Está faltando o duplo ponto-e-vírgula ;; para fechar o bloco do 5).
Está faltando também o bloco 6) mas deve ser momentâneo, não é?

Por enquanto é isto.
Veja se tem mais erro e poste a mensagem.

----------------------------------------------------------------------------------------------------------------
Nem direita, nem esquerda. Quando se trata de corrupção o Brasil é ambidestro.
(anônimo)

Encryption works. Properly implemented strong crypto systems are one of the few things that you can rely on. Unfortunately, endpoint security is so terrifically weak that NSA can frequently find ways around it. — Edward Snowden


3. Re: Erro de sintaxe [RESOLVIDO]

Perfil removido
removido

(usa Nenhuma)

Enviado em 22/10/2016 - 16:51h

Essa linha 77 parece um pedaço de uma estrutura case ... esac que tem algum problema ou está incompleta.
Seria melhor passar o código inteiro e de preferência entre [ code ] e [ /code ] como em

case ...

;;

esac


para manter as tabulações.

O que faz isto é o botão </> no formulário de resposta.
Não dá para saber sem ver o código inteiro.

----------------------------------------------------------------------------------------------------------------
Nem direita, nem esquerda. Quando se trata de corrupção o Brasil é ambidestro.
(anônimo)

Encryption works. Properly implemented strong crypto systems are one of the few things that you can rely on. Unfortunately, endpoint security is so terrifically weak that NSA can frequently find ways around it. — Edward Snowden



4. Script inteiro

Wellington Luiz de Almeida Junior
Wellingtonty

(usa Debian)

Enviado em 22/10/2016 - 17:26h

listeiro_037 escreveu:

Essa linha 77 parece um pedaço de uma estrutura case ... esac que tem algum problema ou está incompleta.
Seria melhor passar o código inteiro e de preferência entre [ code ] e [ /code ] como em

case ...

;;

esac


para manter as tabulações.

O que faz isto é o botão </> no formulário de resposta.
Não dá para saber sem ver o código inteiro.

----------------------------------------------------------------------------------------------------------------
Nem direita, nem esquerda. Quando se trata de corrupção o Brasil é ambidestro.
(anônimo)

Encryption works. Properly implemented strong crypto systems are one of the few things that you can rely on. Unfortunately, endpoint security is so terrifically weak that NSA can frequently find ways around it. — Edward Snowden


#!/bin/bash

clear
while true; do
echo "==========================================================
Digite o número do componente a ser instalado:
1 - Configuração da rede
2 - Sourcers.list recomendada
3 - Samba 4, Cups, Dhcp
4 - Squid 3, Sarg, Ntop
5 - Apache2, Ftp, Sql, Moodle
6 - Postfix, Squirrelmail, Sql
0 - Sair
==========================================================="
echo -n "->OPÇÃO: "

read opcao

#verificar se foi digitada uma opcao
if [ -z $opcao ]; then
echo "ERRO: digite uma opcao"
exit
fi

case $opcao in
1)
echo source /etc/network/interfaces.d/* &&
echo auto lo >> /etc/network/interfaces &&
echo iface lo inet loopback >> /etc/network/interfaces &&
echo auto eth0 >> /etc/network/interfaces &&
echo iface eth0 inet dhcp >> /etc/network/interfaces &&
echo auto eth1 >> /etc/network/interfaces &&
echo iface eth1 inet static >> /etc/network/interfaces &&
echo address 192.168.0.4 >> /etc/network/interfaces &&
echo network 192.168.0.0 >> /etc/network/interfaces &&
echo netmask 255.255.255.0 >> /etc/network/interfaces &&
/etc/init.d/networking restart;;
2)
echo #------------------------------------------------------------------------------# /etc/apt/sourcers.list &&
echo # OFFICIAL DEBIAN REPOS # /etc/apt/sourcers.list &&
echo #------------------------------------------------------------------------------# /etc/apt/sourcers.list &&
echo ###### Debian Main Repos /etc/apt/sourcers.list &&
echo deb http://ftp.br.debian.org/debian/ jessie main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://ftp.br.debian.org/debian/ jessie main contrib non-free /etc/apt/sourcers.list &&
echo ###### Debian Update Repos /etc/apt/sourcers.list &&
echo deb http://security.debian.org/ jessie/updates main contrib non-free /etc/apt/sourcers.list &&
echo deb http://ftp.br.debian.org/debian/ jessie-proposed-updates main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://security.debian.org/ jessie/updates main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://ftp.br.debian.org/debian/ jessie-proposed-updates main contrib non-free /etc/apt/sourcers.list ;;
3)
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc">http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - &&
sudo apt-get update &&
sudo apt-get install virtualbox;;
4)
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" >> /etc/apt/sources.list' &&
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc">http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - &&
sudo apt-get update &&
sudo apt-get install virtualbox;;
5)
apt-get update
apt-get upgrade
apt-get install apache2 mysql-server php5-mysql
mysql_install_db
mysql_secure_installation
apt-get install php5 libapache2-mod-php5 php5-mcrypt
rm /etc/apache2/mods-enabled/dir.conf
echo "<IfModule mod_dir.c>" >> /etc/apache2/mods-enabled/dir.conf
echo DirectoryIndex index.php index.cgi index.pl index.html index.xhtml index.htm /etc/apache2/mods-enabled/dir.conf >> /etc/apache2/mods-enabled/dir.conf
echo "</IfModule>" >> /etc/apache2/mods-enabled/dir.conf
service apache2 restart
mkdir /Moodle
chmod 777 /Moodle
cd /var/www/html/
wget https://download.moodle.org/download.php/stable31/moodle-latest-31.zip
apt-get install zip unzip
unzip moodle-latest-31.zip
0)
echo "Saindo..."
exit;;
*)
echo
echo "ERRO: opção inválida"
echo ;;
esac
done



5. Re: Erro de sintaxe [RESOLVIDO]

Wellington Luiz de Almeida Junior
Wellingtonty

(usa Debian)

Enviado em 22/10/2016 - 18:01h

Nessa parte sua soluçao funcionou perfeitamente, agora fiz algumas alteraçoes novas e esta exibindo um novo erro na line 79

Segue o script
#!/bin/bash

clear
while true; do
echo "==========================================================
Digite o número do componente a ser instalado:
1 - Configuração da rede
2 - Sourcers.list recomendada
3 - Samba 4, Cups, Dhcp
4 - Squid 3, Sarg, Ntop
5 - Apache2, Ftp, Sql, Moodle
6 - Postfix, Squirrelmail, Sql
0 - Sair
==========================================================="
echo -n "->OPÇÃO: "

read opcao

#verificar se foi digitada uma opcao
if [ -z $opcao ]; then
echo "ERRO: digite uma opcao"
exit
fi

case $opcao in
1)
echo source /etc/network/interfaces.d/* &&
echo auto lo >> /etc/network/interfaces &&
echo iface lo inet loopback >> /etc/network/interfaces &&
echo auto eth0 >> /etc/network/interfaces &&
echo iface eth0 inet dhcp >> /etc/network/interfaces &&
echo auto eth1 >> /etc/network/interfaces &&
echo iface eth1 inet static >> /etc/network/interfaces &&
echo address 192.168.0.4 >> /etc/network/interfaces &&
echo network 192.168.0.0 >> /etc/network/interfaces &&
echo netmask 255.255.255.0 >> /etc/network/interfaces &&
/etc/init.d/networking restart;;
2)
echo #------------------------------------------------------------------------------# /etc/apt/sourcers.list &&
echo # OFFICIAL DEBIAN REPOS # /etc/apt/sourcers.list &&
echo #------------------------------------------------------------------------------# /etc/apt/sourcers.list &&
echo ###### Debian Main Repos /etc/apt/sourcers.list &&
echo deb http://ftp.br.debian.org/debian/ jessie main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://ftp.br.debian.org/debian/ jessie main contrib non-free /etc/apt/sourcers.list &&
echo ###### Debian Update Repos /etc/apt/sourcers.list &&
echo deb http://security.debian.org/ jessie/updates main contrib non-free /etc/apt/sourcers.list &&
echo deb http://ftp.br.debian.org/debian/ jessie-proposed-updates main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://security.debian.org/ jessie/updates main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://ftp.br.debian.org/debian/ jessie-proposed-updates main contrib non-free /etc/apt/sourcers.list ;;
3)
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - &&
sudo apt-get update &&
sudo apt-get install virtualbox;;
4)
apt-get update
apt-get upgrade
apt-get install squid3
cd /etc/squid3/
cp squid.conf squid.confbackup
rm squid.conf
echo acl SSL_ports port 443 >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 80 # http >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 21 # ftp >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 443 # https >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 70 # gopher >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 210 # wais >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 1025-65535 # unregistered ports >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 280 # http-mgmt >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 488 # gss-http >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 591 # filemaker >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 777 # multiling http >> /etc/squid3/squid.conf &&
echo acl CONNECT method CONNECT >> /etc/squid3/squid.conf &&
echo http_access allow localhost >> /etc/squid3/squid.conf &&
echo acl block url_regex -i "/etc/squid3/block.txt" >> /etc/squid3/squid.conf &&
echo http_access deny block >> /etc/squid3/squid.conf &&
echo http_access allow all >> /etc/squid3/squid.conf &&
echo refresh_pattern ^ftp: 1440 20% 10080 >> /etc/squid3/squid.conf &&
echo refresh_pattern ^gopher: 1440 0% 1440 >> /etc/squid3/squid.conf &&
echo refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 >> /etc/squid3/squid.conf &&
echo refresh_pattern . 0 20% 4320 >> /etc/squid3/squid.conf &&
echo www.facebook.com >> /etc/squid3/block.txt &&
echo www.youtube.com >> /etc/squid3/block.txt &&
echo www.gmail.com >> /etc/squid3/block.txt &&
echo #!/bin/bash >> /etc/init.d/compartilhar.sh &&
echo iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128 >> /etc/init.d/compartilhar.sh &&
echo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE >> /etc/init.d/compartilhar.sh &&
echo echo 1 > /proc/sys/net/ipv4/ip_forward >> /etc/init.d/compartilhar.sh &&
echo echo 1 > /proc/sys/net/ipv4/ip_forward >> /etc/init.d/compartilhar.sh &&
/etc/init.d/squid3 restart;;
5)
apt-get update &&
apt-get upgrade &&
apt-get install apache2 mysql-server php5-mysql &&
mysql_install_db &&
mysql_secure_installation &&
apt-get install php5 libapache2-mod-php5 php5-mcrypt &&
rm /etc/apache2/mods-enabled/dir.conf &&
echo "<IfModule mod_dir.c>" >> /etc/apache2/mods-enabled/dir.conf &&
echo DirectoryIndex index.php index.cgi index.pl index.html index.xhtml index.htm /etc/apache2/mods-enabled/dir.conf >> /etc/apache2/mods-enabled/dir.conf &&
echo "</IfModule>" >> /etc/apache2/mods-enabled/dir.conf &&
service apache2 restart &&
mkdir /Moodle &&
chmod 777 /Moodle &&
cd /var/www/html/ &&
wget https://download.moodle.org/download.php/stable31/moodle-latest-31.zip &&
apt-get install zip unzip &&
unzip moodle-latest-31.zip &&
0)
echo "Saindo..."
exit;;
*)
echo
echo "ERRO: opção inválida"
echo ;;
esac
done



Erro referente a esta line "echo refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 >> /etc/squid3/squid.conf &&"


6. Re: Erro de sintaxe [RESOLVIDO]

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 22/10/2016 - 18:31h

Wellingtonty escreveu:

Nessa parte sua soluçao funcionou perfeitamente, agora fiz algumas alteraçoes novas e esta exibindo um novo erro na line 79

Segue o script
#!/bin/bash

clear
while true; do
echo "==========================================================
Digite o número do componente a ser instalado:
1 - Configuração da rede
2 - Sourcers.list recomendada
3 - Samba 4, Cups, Dhcp
4 - Squid 3, Sarg, Ntop
5 - Apache2, Ftp, Sql, Moodle
6 - Postfix, Squirrelmail, Sql
0 - Sair
==========================================================="
echo -n "->OPÇÃO: "

read opcao

#verificar se foi digitada uma opcao
if [ -z $opcao ]; then
echo "ERRO: digite uma opcao"
exit
fi

case $opcao in
1)
echo source /etc/network/interfaces.d/* &&
echo auto lo >> /etc/network/interfaces &&
echo iface lo inet loopback >> /etc/network/interfaces &&
echo auto eth0 >> /etc/network/interfaces &&
echo iface eth0 inet dhcp >> /etc/network/interfaces &&
echo auto eth1 >> /etc/network/interfaces &&
echo iface eth1 inet static >> /etc/network/interfaces &&
echo address 192.168.0.4 >> /etc/network/interfaces &&
echo network 192.168.0.0 >> /etc/network/interfaces &&
echo netmask 255.255.255.0 >> /etc/network/interfaces &&
/etc/init.d/networking restart;;
2)
echo #------------------------------------------------------------------------------# /etc/apt/sourcers.list &&
echo # OFFICIAL DEBIAN REPOS # /etc/apt/sourcers.list &&
echo #------------------------------------------------------------------------------# /etc/apt/sourcers.list &&
echo ###### Debian Main Repos /etc/apt/sourcers.list &&
echo deb http://ftp.br.debian.org/debian/ jessie main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://ftp.br.debian.org/debian/ jessie main contrib non-free /etc/apt/sourcers.list &&
echo ###### Debian Update Repos /etc/apt/sourcers.list &&
echo deb http://security.debian.org/ jessie/updates main contrib non-free /etc/apt/sourcers.list &&
echo deb http://ftp.br.debian.org/debian/ jessie-proposed-updates main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://security.debian.org/ jessie/updates main contrib non-free /etc/apt/sourcers.list &&
echo deb-src http://ftp.br.debian.org/debian/ jessie-proposed-updates main contrib non-free /etc/apt/sourcers.list ;;
3)
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - &&
sudo apt-get update &&
sudo apt-get install virtualbox;;
4)
apt-get update
apt-get upgrade
apt-get install squid3
cd /etc/squid3/
cp squid.conf squid.confbackup
rm squid.conf
echo acl SSL_ports port 443 >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 80 # http >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 21 # ftp >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 443 # https >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 70 # gopher >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 210 # wais >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 1025-65535 # unregistered ports >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 280 # http-mgmt >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 488 # gss-http >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 591 # filemaker >> /etc/squid3/squid.conf &&
echo acl Safe_ports port 777 # multiling http >> /etc/squid3/squid.conf &&
echo acl CONNECT method CONNECT >> /etc/squid3/squid.conf &&
echo http_access allow localhost >> /etc/squid3/squid.conf &&
echo acl block url_regex -i "/etc/squid3/block.txt" >> /etc/squid3/squid.conf &&
echo http_access deny block >> /etc/squid3/squid.conf &&
echo http_access allow all >> /etc/squid3/squid.conf &&
echo refresh_pattern ^ftp: 1440 20% 10080 >> /etc/squid3/squid.conf &&
echo refresh_pattern ^gopher: 1440 0% 1440 >> /etc/squid3/squid.conf &&
echo refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 >> /etc/squid3/squid.conf &&
echo refresh_pattern . 0 20% 4320 >> /etc/squid3/squid.conf &&
echo www.facebook.com >> /etc/squid3/block.txt &&
echo www.youtube.com >> /etc/squid3/block.txt &&
echo www.gmail.com >> /etc/squid3/block.txt &&
echo #!/bin/bash >> /etc/init.d/compartilhar.sh &&
echo iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128 >> /etc/init.d/compartilhar.sh &&
echo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE >> /etc/init.d/compartilhar.sh &&
echo echo 1 > /proc/sys/net/ipv4/ip_forward >> /etc/init.d/compartilhar.sh &&
echo echo 1 > /proc/sys/net/ipv4/ip_forward >> /etc/init.d/compartilhar.sh &&
/etc/init.d/squid3 restart;;
5)
apt-get update &&
apt-get upgrade &&
apt-get install apache2 mysql-server php5-mysql &&
mysql_install_db &&
mysql_secure_installation &&
apt-get install php5 libapache2-mod-php5 php5-mcrypt &&
rm /etc/apache2/mods-enabled/dir.conf &&
echo "<IfModule mod_dir.c>" >> /etc/apache2/mods-enabled/dir.conf &&
echo DirectoryIndex index.php index.cgi index.pl index.html index.xhtml index.htm /etc/apache2/mods-enabled/dir.conf >> /etc/apache2/mods-enabled/dir.conf &&
echo "</IfModule>" >> /etc/apache2/mods-enabled/dir.conf &&
service apache2 restart &&
mkdir /Moodle &&
chmod 777 /Moodle &&
cd /var/www/html/ &&
wget https://download.moodle.org/download.php/stable31/moodle-latest-31.zip &&
apt-get install zip unzip &&
unzip moodle-latest-31.zip &&
0)
echo "Saindo..."
exit;;
*)
echo
echo "ERRO: opção inválida"
echo ;;
esac
done

Erro referente a esta line "echo refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 >> /etc/squid3/squid.conf &&"


====================================================================

Boa noite, Wellingtonty.
Coloque o conteúdo dos "echos" entre aspas . . .
Exemplo:
echo "refresh_pattern -i (/cgi-bin/|\?) 0 0% 0" >> /etc/squid3/squid.conf && 


att.:
marcelo oliver




7. Resolvido

Wellington Luiz de Almeida Junior
Wellingtonty

(usa Debian)

Enviado em 22/10/2016 - 18:56h

Muito obrigado a ajuda de todos , em breve o script estara pronto e irei posta lo aki no VoL



8. Re: Erro de sintaxe

Perfil removido
removido

(usa Nenhuma)

Enviado em 22/10/2016 - 19:01h

Ao invés de usar vários echo você pode usar o comando cat:

cat >> arquivo.txt << EOF
a
b
c
d
e
f
g
h
EOF


O comando acima lê todo o texto entre o comando cat e EOF e escreve o que houver entre eles em arquivo.txt.
EOF é apenas uma marca para o fim de que dados serão escritos.
Encontrou EOF como definido em cat ... << EOF ele escreve e finaliza a escrita.

----------------------------------------------------------------------------------------------------------------
Nem direita, nem esquerda. Quando se trata de corrupção o Brasil é ambidestro.
(anônimo)

Encryption works. Properly implemented strong crypto systems are one of the few things that you can rely on. Unfortunately, endpoint security is so terrifically weak that NSA can frequently find ways around it. — Edward Snowden







Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts