我知道这里有其他的帖子,但我不能让他们中的任何人工作。我的问题是我想在我的rpi上创建一个脚本来自动更改wifi网络并在静态和dhcp之间更改eth0。它尚未完成我目前只在无线部分工作。但剧本至今读...如何使用Bash脚本将测试发送到某一行
#!/bin/bash
ANS=''
ssid=''
psk=''
file='/etc/network/interfaces'
function wireless {
echo 'The wireless network '$ssid' has now been set up'
start
}
function ssid {
echo 'What is your Network SSID?'
echo -e '> \c'
read ssid
echo 'You entered '$ssid'. Is this correct? (y/n)'
echo -e '> \c'
read ANS
if [ $ANS = 'y' ]; then
psk
else
echo 'Please renter your SSID'
ssid
fi
}
function psk {
echo 'What is your Network PSK?'
echo -e '> \c'
read psk
echo 'You entered '$psk'. Is this correct? (y/n)'
echo -e '> \c'
read ANS
if [ $ANS = 'y' ]; then
wireless
else
echo 'Please renter your PSK'
psk
fi
}
function start {
echo 'What do you want to do?'
echo ''
echo 'Press w to set up wireless ssid and psk'
echo 'Press s to change eth0 to a static ip address'
echo 'Press d to change eth0 to a dhcp ip address'
echo ''
echo 'Or press ctrl+c to quit'
echo -e '> \c'
read ANS
if [ $ANS = 'w' ]; then
ssid
else
if [ $ANS = 's' ]; then
static
else
if [ $ANS = 'd' ]; then
dhcp
fi
fi
fi
}
#backup of /etc/network/interfaces
#auto lo
#iface lo inet loopback
#iface eth0 inet dhcp
#iface eth0 inet static
# address ###########
# netmask #############
# broadcast ###########
# gateway ##########
#
#allow-hotplug wlan0
#
#auto wlan0
#
#iface wlan0 inet dhcp
#wpa-ssid "Home Network"
#wpa-psk "psk"
start
exit 0
所以就是所有罚款,但在功能上无线,我想送PSK和SSID,以线15和16的/ etc /网络/接口。请有人告诉我最好的方法来做到这一点。 谢谢
谢谢 - 这是一个优秀的awnser – user1205406