autoconnect to telnet server.
Alex F. Evonosky
alex at alexevon.org
Mon Jul 9 15:38:46 UTC 2007
you can use an expect script to accomplish this...
#!/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
}
}
#
set USER [exec cat user]
set PASS [exec cat pass]
set timeout 10
set send_slow {1 .1}
#
spawn $env(SHELL)
match_max 100000
spawn telnet 1.2.3.4
expect -exact ":"
send -s -- "$USER\r"
expect -exact ":"
send -s -- "$PASS\r"
expect -exact "#"
send -s -- "[enter commands here]\r"
expect -exact ":"
send -s -- "exit\r"
Guillaume wrote:
> Hi,
> I would like to use the telnet client via with cron & script to
> execute special command on a telnet server.
> On telnet manual i saw the -l option used to specify the user. But i
> dont find any way to give the password (of course in clear text, i
> dont speak here about security).
> I try several commands like
> ] telnet -l $user host <passwdor
> ] echo password | telnet -l $user host
> ]cat passwordfile | telnet -l $user host
> None of this works. Does someone can help me ?
> Thanks.
>
More information about the fedora-list
mailing list