Telnet IP from file

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Identis
Junior Coder
Posts: 26
Joined: Fri Mar 27, 2015 11:26 am

Telnet IP from file

Post by Identis » Wed Oct 19, 2016 9:51 am

Hello,

I want to configure a lot of telnet sessions, but I want to read IP adresses from file, so it will be easier to modify in future, dont need to compile every time if I will change something. Is it possible? Thanks.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Telnet IP from file

Post by Marcus Tettmar » Wed Oct 19, 2016 11:58 am

Yes, use ReadFile, or ReadLN or ReadIniFile functions.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Identis
Junior Coder
Posts: 26
Joined: Fri Mar 27, 2015 11:26 am

Re: Telnet IP from file

Post by Identis » Wed Oct 19, 2016 12:57 pm

Marcus Tettmar wrote:Yes, use ReadFile, or ReadLN or ReadIniFile functions.
Thank you :)

Identis
Junior Coder
Posts: 26
Joined: Fri Mar 27, 2015 11:26 am

Re: Telnet IP from file

Post by Identis » Wed Oct 19, 2016 1:03 pm

Now I have other problem. In txt file I have 3 lines with IP, if I run my code i get only second line ip backuped up, if I use debug to check everything step by step all 3 IP is backuped.

Code: Select all

Let>k=1
While>line<>##EOF##
    ReadLn>C:\temp\ip.txt,k,line
    If>ipas<>##EOF##
TelnetConnect>line,23,hTN
TelnetWaitFor>hTN,login,5,r
TelnetSend>hTN,admin%CR%
TelnetWaitFor>hTN,password,5,r
TelnetSend>hTN,pass%CR%
TelnetWaitFor>hTN,>,5,r
TelnetSend>hTN,_cmdline-mode on%CR%
TelnetWaitFor>hTN,],5,r
TelnetSend>hTN,Y%CR%
TelnetWaitFor>hTN,password,5,r
TelnetSend>hTN,512900%CR%
TelnetWaitFor>hTN,>,5,r
TelnetSend>hTN,tftp tftp_ip put startup.cfg /tftpboot/Config_%line%.cfg%CR%
TelnetClose>hTN
    Endif
    Let>k=k+1
EndWhile

Exit>0


User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Telnet IP from file

Post by CyberCitizen » Fri Oct 28, 2016 2:24 am

What about a telnet wait command after sending that last line with the .cfg in it. Could that be taking longer to process before your closing the connection? Can you add a brief wait line at the end before continuing?

Very hard to see what's occurring / test without the servers etc.

If it works though the debugger stepping through, then it's usually an issue with timing.
FIREFIGHTER

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts