Enviado em 26/11/2019 - 09:57h
Bom dia, estou tentanto fazer um script para configurar a interface de rede com o Zenity, prém gostaria que se o usuario não atribuisse valor para um determinada variavel, a linha que seria escrita com esse valor seja apagada.Exemplo
O usuario não atribui valor para broadcast, entao o script ira adicionar a linha:
broadcast
após isso ele a apgue.
Meu script :
#!/bin/bash
inte="/etc/network/interfaces"
echo "# Interfaces" >$inte
DADOS=$(zenity --forms --title="Interface" --text="Preencha com as informações nescessárias:" \
--separator="," \
--add-entry="Address" \
--add-entry="Netmask" \
--add-entry="Network" \
--add-entry="Broadcast" \
--add-entry="Gateway" \
--add-entry="Network Adapter")
ad=$(echo $DADOS | cut -d, -f1)
nm=$(echo $DADOS | cut -d, -f2)
nt=$(echo $DADOS | cut -d, -f3)
bc=$(echo $DADOS | cut -d, -f4)
gt=$(echo $DADOS | cut -d, -f5)
eth=$(echo $DADOS | cut -d, -f6)
echo "auto $eth" >>$inte
echo "iface $eth inet static" >>$inte
echo "address $ad" >>$inte
echo "netmask $nm" >>$inte
echo "netwok $nt" >>$inte
echo "broadcast $bc" >>$inte
echo "gateway $gt" >>$inte
cat $inte
O usuario não atribui valor para broadcast, entao o script ira adicionar a linha:
broadcast
após isso ele a apgue.
Meu script :
#!/bin/bash
inte="/etc/network/interfaces"
echo "# Interfaces" >$inte
DADOS=$(zenity --forms --title="Interface" --text="Preencha com as informações nescessárias:" \
--separator="," \
--add-entry="Address" \
--add-entry="Netmask" \
--add-entry="Network" \
--add-entry="Broadcast" \
--add-entry="Gateway" \
--add-entry="Network Adapter")
ad=$(echo $DADOS | cut -d, -f1)
nm=$(echo $DADOS | cut -d, -f2)
nt=$(echo $DADOS | cut -d, -f3)
bc=$(echo $DADOS | cut -d, -f4)
gt=$(echo $DADOS | cut -d, -f5)
eth=$(echo $DADOS | cut -d, -f6)
echo "auto $eth" >>$inte
echo "iface $eth inet static" >>$inte
echo "address $ad" >>$inte
echo "netmask $nm" >>$inte
echo "netwok $nt" >>$inte
echo "broadcast $bc" >>$inte
echo "gateway $gt" >>$inte
cat $inte