Telnet Scripting Tool v.1.0 by Albert Yale

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
1981nasr
Posts: 7
Joined: 26 May 2020 07:26

Telnet Scripting Tool v.1.0 by Albert Yale

#1 Post by 1981nasr » 27 May 2020 13:40

Example to use Telnet Scripting Tool v.1.0 by Albert Yale
I have use use vbs file to connect using Telnet.
set WshShell = WScript.CreateObject("WScript.Shell")
'Se connecter au Routeur via son IP
'Ajouter un délai de 0.5 secondes en utilisant le paramètre Sleep 500 après chaque commande
WshShell.Run "C:\Windows\System32\telnet.exe Adresse_Serveur -f collecte_SATS.txt",TRUE
WScript.Sleep 500
'Donner Utilisateur
WshShell.SendKeys"station"
WshShell.SendKeys("{Enter}")
WScript.Sleep 500
'Donner Mot de passe
WshShell.SendKeys"station"
WshShell.SendKeys("{Enter}")
WScript.Sleep 500
'Acces A LA BASE
WshShell.SendKeys"2"
WshShell.SendKeys("{Enter}")
WScript.Sleep 500
WshShell.SendKeys"DONNEES A RECUPERER"
WshShell.SendKeys("{Enter}")
WScript.Sleep 500

I ask you to provide examples of how to use this script.
Otherwise if there are other tools in command in exe to make telnet and provide the results in text file.
I had tried using vbs telnet -f it bug a lot and print the results to the current file.

ShadowThief
Expert
Posts: 964
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#2 Post by ShadowThief » 27 May 2020 15:35

The usage is provided when you run the executable:

Code: Select all

Usage Syntax:

tst10.exe /r:script.txt [options]

/r:script.txt      run script.txt
[options]          any of these:

/o:output.txt      send session output to output.txt
/m                 run script in minimized window

Usage Example:

tst10.exe /r:script.txt /o:output.txt /m

Scripting Syntax:

HOSTNAME PORT      port number optional, default: 23
WAIT "string"      string to wait for
SEND "string"      string to send
\"                 represents the a quote character
\m                 represents a <CR/LF>
\\                 represents the backslash character

Scripting Example:

hostname.com 23
WAIT "login"
SEND "root\m"
WAIT "password"
SEND "mypassword\m"
WAIT ">"
SEND "dip internet.dip\m"
WAIT ">"

Scripting Note:

You can start with either WAIT or SEND commands,
but you *must* alternate them. ie: you can't use two
or more WAIT or SEND in a row.

Note:

TST will disconnect and close as soon
as its done with the last entry of the script.

If you need to, you can type in the terminal
window while the script is running.

1981nasr
Posts: 7
Joined: 26 May 2020 07:26

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#3 Post by 1981nasr » 27 May 2020 17:10

file named as script.txt
Adress
WAIT "500"
SEND "login\m"
WAIT "500"
SEND "password\m"
WAIT "500"
SEND "2\m"
WAIT "500"
SEND "SNTS//\m"
WAIT "500"
SEND "b\m"
WAIT "500"
SEND "3\m"
When execute tst10.exe /r:script.txt /o:output.txt /m
the script demand LOGIN

ShadowThief
Expert
Posts: 964
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#4 Post by ShadowThief » 28 May 2020 00:10

WAIT is waiting for a response string, not for a specified amount of time. You have to tell it what the server is going to say. I can't help you with that since I don't have access to it.

1981nasr
Posts: 7
Joined: 26 May 2020 07:26

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#5 Post by 1981nasr » 28 May 2020 05:27

Red Hat Linux release 8.0 (Psyche)
Kernel 2.4.18-14 on an i686
login: station
Password:
Last login: Tue Jun 2 11:05:18 from 192.168.x.x
*************************
* SYSTEME *
*************************
Heure UTC : 11:08
1. Emission des messages
2. Acces a la base de donnees
3. Fin de session Entrer le choix : 2
Entrez une requete comme celles-ci (entrer b pour finir):
sats//
sats// dtta 051200
sa dtta daag gmmc
sm 60715 60714
Sm 60780
60780 13960 00306 10236 20116 39826 40121 51017 60004
333 20219=
Entrez une requete comme celles-ci (entrer b pour finir):
sats//
sats// dtta 051200
sa dtta daag gmmc
sm 60715 60714
b
*************************
* SYSTEME *
*************************
Heure UTC : 11:08
1. Emission des messages
2. Acces a la base de donnees
3. Fin de session
Entrer le choix : 3
Attachments
example telnet.jpg
example telnet.jpg (65.51 KiB) Viewed 848 times
Last edited by 1981nasr on 02 Jun 2020 05:23, edited 1 time in total.

Squashman
Expert
Posts: 4160
Joined: 23 Dec 2011 13:59

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#6 Post by Squashman » 28 May 2020 10:44

Still baffles me when people take screenshot of the console when it is so easy to copy the text from it and paste it into the forums.

ShadowThief
Expert
Posts: 964
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#7 Post by ShadowThief » 28 May 2020 10:46

I'll let you figure out what you need to do for the last part where you enter a 3.

Code: Select all

@echo off
(
	echo address
	echo WAIT "login"
	echo SEND "your_login\m"
	echo WAIT "password"
	echo SEND "your_password\m"
	echo WAIT "Entrer le choix :"
	echo SEND "2\m"
	echo WAIT "Entrez une requete comme celles-ci (entrer b pour finir):"
	echo SEND "SNTS//\m"
	echo WAIT "Entrez une requete comme celles-ci (entrer b pour finir):"
	echo SEND "b\m"
) >script.txt
start "" tst10.exe /r:script.txt /o:output.txt

1981nasr
Posts: 7
Joined: 26 May 2020 07:26

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#8 Post by 1981nasr » 28 May 2020 13:24

I had tested the script by following your comments
It works but our script accesses a database, it takes a delay to retrieve the data before waiting for the next character string to meet.
I await your answers.
Last edited by 1981nasr on 30 May 2020 08:15, edited 1 time in total.

ShadowThief
Expert
Posts: 964
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#9 Post by ShadowThief » 28 May 2020 15:23

The WAIT command will wait until the text that you tell it to wait for appears. Presumably the server displays something when it's ready to accept input, so just give the script that text and it will wait until that text appears before moving on to the next command.

1981nasr
Posts: 7
Joined: 26 May 2020 07:26

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#10 Post by 1981nasr » 29 May 2020 05:55

This script excute one line
Attachments
exempla execution telnet.jpg
exempla execution telnet.jpg (286.15 KiB) Viewed 793 times

1981nasr
Posts: 7
Joined: 26 May 2020 07:26

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#11 Post by 1981nasr » 29 May 2020 05:58

You can see the difference between running telnet via cmd and running via script.
Via DOS telnet works normally but with the script it hangs after the display of the first line.

penpen
Expert
Posts: 1822
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Telnet Scripting Tool v.1.0 by Albert Yale

#12 Post by penpen » 03 Jun 2020 14:56

You seem to wait for different strings, when reaching the same menue (or do i missinterpret what i see?):
"sm 60715 60714" versus "Entrez une requete comme celles-ci (entrer b pour finir):".

I am not familiar with the Telnet Scripting Tool, but maybe your second wait doesn't work, because it doesn't end in the second string, you could try using the first string again (which seemed to have worked).


penpen

Post Reply