Telnet Scripting Tool v.1.0 by Albert Yale
Moderator: DosItHelp
Telnet Scripting Tool v.1.0 by Albert Yale
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.
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.
-
- Expert
- Posts: 1162
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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.
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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
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
-
- Expert
- Posts: 1162
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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.
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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
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 (65.51 KiB) Viewed 11646 times
Last edited by 1981nasr on 02 Jun 2020 05:23, edited 1 time in total.
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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.
-
- Expert
- Posts: 1162
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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.
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.
-
- Expert
- Posts: 1162
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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.
Re: Telnet Scripting Tool v.1.0 by Albert Yale
This script excute one line
- Attachments
-
- exempla execution telnet.jpg (286.15 KiB) Viewed 11591 times
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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.
Via DOS telnet works normally but with the script it hangs after the display of the first line.
Re: Telnet Scripting Tool v.1.0 by Albert Yale
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
"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