Re: autoconnect to telnet server.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
>

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux