I figured out how to enable/disable my wireless connection with telnet, but I want to automate it.
I read telnet is not suitable for this, and one should use netcat instead.
This is what I have:
nc 192.168.1.254 23 << EOF
username
password
:wireless ifconfig state=$1
EOF
But when I run that I get something like:
????????Username : Administratorfietspomp:wireless i
Some searching turned up the -t and -i options, but neither help very much.
update
Expect it is:
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
if { [lindex $argv 0] == 1} {
set status "enabled"
} else {
set status "disabled"
}
set timeout -1
spawn telnet 192.168.1.254
match_max 100000
expect -exact "Username : "
send -- "username\r"
expect -exact "Password : "
send -- "password\r"
expect -exact "_{Administrator}=>"
send -- ":wireless ifconfig state=$status\r"
expect *
send -- "exit\r"
expect eof