osx - Using expect on a Mac to access a router via telnet -


i'm trying write script on mac should access router via telnet. enhance router's power, cannot done via web.

the problem telnet channel blocked, , in order unlock need run following instruction:

/users/shared/telnetenable - 200cc8132a36 admin password >/dev/udp/192.168.0.1/23 

now, can open telnet connection, in order send commands router need expect. so, file begins with:

#!/usr/bin/expect -f 

and instructions preceded spawn, e.g.

spawn telnet 192.168.0.1 

while command sent router is:

send "wl -a wl0 txpwr 100\n" 

my problem not know how run via spawn instruction unlocks telnet on router. can me?

you don't have use spawn run non-interactive command. tcl's exec command enough. example:

#!/usr/bin/expect  # ``/dev/udp/host/port'' syntax bash specific exec bash -c "/users/shared/telnetenable - 200cc8132a36 \               admin password > /dev/udp/192.168.0.1/23"  spawn telnet 192.168.0.1 ... ... 

expect has system command can also

system "/users/shared/telnetenable - 200cc8132a36 \         admin password > /dev/udp/192.168.0.1/23" 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -