Batch script help

Soldato
Joined
23 Mar 2007
Posts
2,553
Location
Essex
Evening all

I was just wondering if someone could lend me a hand creating a small batch file. Basically all i want to do is create a batch that will launch the cmd and telnet into my router, if its possible would i be able to add my username and password to the script as well?

All i really would like to enter in the batch is

telnet 192.168.1.1

username

password

adsl info --stats

Hope someone can lend me a hand

thanks a mill
 
The user name and password are they for windows? if yes then it wont work as you need to be logged on for the script to run.

Code:
@echo off
telnet 192.168.1.1 -lUSERNAME

adsl info --stats

Not really very clean there are better ways of doing it any you would probably be better off with a 3rd party telnet client rather than the built in one as some will allow you to put the password in the command line arguments.
 
Thanks so much for that mate, the username and password is just the standard router one not windows. Is there such a command to input the data i want like a username and password?

If not do you know of any good thrid party telent clients? i have heard of putty but thats the only one off the top of my head

thanks so much again
 
the Code Above will input the username (replace USERNAME with the one you want to use) but you will still have to type the password, this is a security 'Feature'.

Here is your answer download and unzip to a folder of your choice (empty folder is better) create a cmd file with the following inside

Code:
@echo off
tst10.exe /r:script.txt
exit
Save as Runme.cmd in the folder with tst10.exe.

Now make a txt file with the following edit the USERNAME and YOURPASSWORD to what you need them to be save as script.txt in the same folder as you put tst10.exe
Code:
192.168.1.1 23
wait "login"
SEND "USERNAME\m"
WAIT "password"
SEND "YOURPASSWORD\m"
WAIT ">"
SEND "adsl info --status\m"

and that should be sorted for you :D
 
Last edited:
Gave it a whirl this morning mate but for some reason it would not enter the username and password, this is what i put in the script

192.168.1.1 23
wait "login"
SEND "admin\m"
WAIT "password"
SEND "essien5\m"
WAIT ">"
SEND "adsl info --status\m"

When i run the batch

@Echo off
tst10.exe /r:script.txt
exit

It just gives me the logon screen for the telnet session



Uploaded with ImageShack.us

Thanks again for your help mate
 
Last edited:
Try changing login to Login: and see if that works as all the script is waiting for is the corresponding output to continue on with the script.
 
Thanks again for the mate that seemed to work just fine i have edited the commands so they read exactly like the cmd

192.168.1.1 23
wait "Login:"
SEND "admin\m"
WAIT "Password:"
SEND "essien5\m"
WAIT ">"
SEND "adsl info --stats\m"

The only slight issue i have now is when i run the batch it just pops up then dissapears?

Thanks again for helping me out this i really appreciate it
 
in the batch file before the exit put pause in there and it will wait for you to press any key. :)
Code:
@echo off
tst10.exe /r:script.txt
pause
exit
:D
 
Ah right thats where i was going wrong i was putting pause at the end of this script

192.168.1.1 23
wait "login"
SEND "admin\m"
WAIT "password"
SEND "essien5\m"
WAIT ">"
SEND "adsl info --status\m"
PAUSE

Thanks so much for helping me out it kinda makes sense now once you've got the jist of it. Can i just ask what does the \m command actually state? i understand /r mean "run" Also if i want data to be inputted via a script like this is it really as simple as putting "send" then the info i want?

thanks again matey
 
Run the tst10.exe file with no scripts and it will give you all the options you could need for the script and explain what the \m is for, (think its a return/enter statement cannot remember) :-)
 
Last edited:
Sweet thanks so much for that mate i will av a look at that when i get in from work and have a play around with it. I take it those commands will actually only work with that program and not with just the CMD itself

Thanks so much again.
 
Back
Top Bottom