could anybody help with dos commands for this task

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
jraju
Posts: 8
Joined: 27 Jan 2019 05:44

could anybody help with dos commands for this task

#1 Post by jraju » 27 Jan 2019 06:02

Hi, Thanks and am a newbie
i want to access the router status details on the desktop for which i need a batch file to be executed in task scheduler
i have enabled the telnet
what i need is a batch file. Normal execution at dos prompt is given below
when i type cmd and run as admin
i get to the c:windows\system32 prompt
here i issue the command telnet 192.168.1.1 and then press Enter Key
i ge username: prompt, i supply the word admin and press the Enter key
it gets to the next prompt
password: here i will supply the password after getting code help and hen i have to press the Enter Key
it goes to $ prompt
here i have to issue command show status and press Enter
now i get the status of the router, like mark, firmware date, present date, speed , adsl mode etc etc
This i want to be seen in the desktop
i will close the screen that is Dos Prompt and it should end.
I will name this batch file and then assign the task to task scheduler in windows
i am ne wo the basic codess
can this be achieved by creating a batch file
Now, instead of opening the router page everytime, i am issuing these commands to get the details
if this could be given as batch file, i could set it as a task so that i could run the task every two hours to know the line and actual status of router page
Would experts help me

jraju
Posts: 8
Joined: 27 Jan 2019 05:44

Re: could anybody help with dos commands for this task

#2 Post by jraju » 28 Jan 2019 05:33

Hi, expecting experts reply
what i want is a simple batch code automatically getting login details like userid and password for my computer.
i do not want the code for any other purpose, except accessing the router statistics of status, which i get by command prompt commands by issuing one command and then pressing the Enter Key.
Telent ip gives the access to router page
As my dlink router is configured as the ip, is it not possible to use comnand codes
sample output, after i access the pgae is given below.
once used telnet commands , the command prompt closes and then gives you login page , prompting to enter user id

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: could anybody help with dos commands for this task

#3 Post by Ed Dyreen » 28 Jan 2019 07:38

Because of US law getting login details like password for my computer. is not allowed to be shared here in working code.

How to get help for a batch script - quickly!

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

Re: could anybody help with dos commands for this task

#4 Post by ShadowThief » 28 Jan 2019 21:02

I think he already has the user name and password and he needs to pass both of those to a login prompt (at least I hope that's what he means; how do you not know your own username and password?). We've definitely covered passing multiple user inputs to a script or program somewhere on here before...

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

Re: could anybody help with dos commands for this task

#5 Post by penpen » 29 Jan 2019 04:39

I currently can't test the following code, but i would try something like:

Code: Select all

::test.bat
@echo off
setlocal enableExtensions disableDelayedExpansion
(
	echo(admin
	echo(the password
	echo(show status
	echo(quit
) | telnet 192.168.1.1 | >"pathToDesktop\routerInfo.txt"  findstr "^"
goto :eof
Maybe you could use command line arguments of telnet to set user and password.

penpen

jraju
Posts: 8
Joined: 27 Jan 2019 05:44

Re: could anybody help with dos commands for this task

#6 Post by jraju » 29 Jan 2019 06:59

Hi, Penpen and others,
Thanks. I do not know about coding ,
Could i use your code for my try.
I want to get the router status of my dlink router .
I do not intend any other thing, that the law does not permit
When i issue a telnet ip command, the command closes to open another prompt at username: and then Password.
This i want to pass without user inputting the same.
The user is admin, and the password , i will substitute with my router password,of my own.
I want these to be present in the codes itself, so it could not ask me to input
and after that i am given a $ sign prompt
here i input show status,
This also i want in the batch file and then it shoud open in desktop and here i want pause until i close it on the desktop
I tried just telnet x xxx and i get the user admin
here i wnat your help.

jraju
Posts: 8
Joined: 27 Jan 2019 05:44

Re: could anybody help with dos commands for this task

#7 Post by jraju » 29 Jan 2019 07:35

Tried that code by saving as bat file
the cmd prompt flashes and closes, and i could not view the result.
The sequence of cmd
telnet xxxx ip
it closes and another cmd prompt with username: here i supply the user id and press Enter
it again asks for password: i supply the password, and it is typed without showing the letters and i press Enter
i get $ prompt
here i issue show status command
i get the result of status, representing status page details of router name, firmware etc, with my most wanted speed upload and download
i wnat this resutl to be displayed in desktop, it should stay there
user has to close it to exit.
I do not think this involves any law matter, i get my status page shown in desktop, without having to logon to router and then issue uid and pw to know the download and upload and connection status
If suppose, any of the members feel that it is not , just they can try by issuing those commands.
I think every router has different lable to show the status
Thanks and expecting your code

jraju
Posts: 8
Joined: 27 Jan 2019 05:44

Re: could anybody help with dos commands for this task

#8 Post by jraju » 30 Jan 2019 04:18

Hi, Expecting reply from the forum
From the code, i understand , echo is equivalent to run, is it
I forgot to mention one thing
I have to open a command prompt as Admin before issuing those commands.
So, should i add echo cmd.exe before all the echos in the code
Hi, I assure you that there is no issue of law in my query.
Only thing is i do not know the dos commands for batch files
i am a newbie to programming language.
I specifically searched fo dos batch files forum to find this forum
Hope to receive the reply

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: could anybody help with dos commands for this task

#9 Post by Ed Dyreen » 30 Jan 2019 11:08

Did you read this ? This site is also very good for beginners It will only take a few ours of your time.

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

Re: could anybody help with dos commands for this task

#10 Post by penpen » 01 Feb 2019 05:25

jraju wrote:
29 Jan 2019 07:35
Tried that code by saving as bat file
the cmd prompt flashes and closes, and i could not view the result.
jraju wrote:
30 Jan 2019 04:18
From the code, i understand , echo is equivalent to run, is it
I should explain the key code lines in detail.

1.
Typically input and output streams of processes/commands in a batch file are connected to the console.
- Everything that you type in at the console is passed via the input stream to the actual process.
- Everything that the actual process sends to the oputput stream ends up at the display of the console window.

The pipe operator ('|') creates two instances of cmd, and reassigns the input and output streams.
"process_1 | process_2 | process_3 | ... | process_n" results in two processes.
Everything that you type in is now send to process_1.
Every output of process_1 is send to the input of process_2.
Every output of process_2 is send to the input of process_3.
...
Every output of process_n is send to the dispaly of the console window.

2.
The '>"path\filename"' redirects the output stream to the file "filename" located in the directory denoted by the given path.

3.
The echo-command just prints (or sends) the text to the output stream of the process that executes this echo command.

4.
So the echo commands in my above above batch sniplet should simulate your inputs and must contain the escaped version of the text you want to type in.
You might have to replace "admin" with your actual telnet username, and "the password" with your telnet password.

The output stream data of telnet is send to the findstr input stream where the command lists all resulting lines and sends the output to the file "routerInfo.txt" located in "pathToDesktop\". So you have to modify the path to the location of your desktop (which i can't know).


Sidenotes:
If you don't want to create a file on your desktop (which is how i understood what you have written above), then remove '>"pathToDesktop\routerInfo.txt" '.

If you want the command window to stay open just add a new line containing "pause" between the pipes and the "goto :eof".

I don't know if that works, because it depends on the behaviour of the "telnet":
- Does it use the input stream or does it explicitely read from cmd-console?
- Does it use the output stream or writes it all data explicitely to the cmd-console?

Maybe you want to read the manpage of your "telnet"-tool to get the command line arguments that might help you doing what you want.

jraju wrote:
30 Jan 2019 04:18
I have to open a command prompt as Admin before issuing those commands.
So, should i add echo cmd.exe before all the echos in the code
There is no need to add cmd.exe before all the echoes:
The child cmd-processes created by pipes use the same user-environment as the initial (parent) cmd-process.


penpen

jraju
Posts: 8
Joined: 27 Jan 2019 05:44

Re: could anybody help with dos commands for this task

#11 Post by jraju » 01 Feb 2019 06:44

Hi, I will go step by step instructions as you say.
One more subquery
is it risky to access the router via batch files
I thought of screen shot of txt file , that i just pasted to a notebook. But as the forum did not allow txt files, i could not.
Here i enclose the results , that i get using telnet command.
When i type telnet xxxx after enabling that from program and features
The cmd closes to this screen and then i supply the admin and pw.
pw is hidden and i just enter and press enter key
rest you know

User Access Verification

Username: admin

Password:

$show status
System
Alias Name : DSL-2730U
Uptime : 0 1:2:12
Date/Time : Sun Jan 27 9:40:4 2019
Firmware Version : IN_1.11

DSL
Operational Status : ADSL2+
Upstream Speed : 621 kbps
Downstream Speed : 12495 kbps

LAN Configuration
IP Address : 192.168.1.xx
Subnet Mask : 255.255.255.0
DHCP Server : Enable
MAC Address :

WAN Configuration
Interface VPI/VCI Encap Droute Protocol IP Address Gateway Status
----------------------------------------------------------
pppoe1 0/xx LLC Off PPPoE Up

$
I removed the public ips in the shown file

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

Re: could anybody help with dos commands for this task

#12 Post by penpen » 01 Feb 2019 19:46

jraju wrote:
01 Feb 2019 06:44
is it risky to access the router via batch files
Well, the above solution stores the telnet user id and the password in a batch file, so yes that is risky.
You might (and should) first read both first (using the 'set /p' command) and store its results in environment variables.
The above were more a proof of concept, and is among other things (mentioned above) depending on how telnet handles dos line endings (in c++ style "\r\n") you might need to change the input data slightly (to get rid of the "\n" characters) - but i can't see what's going on on your PC, so you have to post such information once you tested it.

But if you got your above text file using my above batch it seems you are lucky and only need to change the login/password handling.


penpen

jraju
Posts: 8
Joined: 27 Jan 2019 05:44

Re: could anybody help with dos commands for this task

#13 Post by jraju » 01 Feb 2019 20:08

Hi, penpen
i now understand
I get telent by just going to control panel, program and features, add or remove windows components, and while it populates, find the telnet client and put a tick mart to enable. That is establishing connection with the router, as the telent is by default enabled in router.
I just issue commands , as i have said in my previous posts.
what is environment settings, should i do something there.
do you mean setting environment variables of something in this batch file to work correctly
i just removed the >storing line after pip character and added a pause,
but on executing , the command prompt flashes for a second and vanish.
my dlink router is set as dns server and allotted the ip by the dlink.
could you just modify and repost the commands, if you please.
i am also trying thro selenium surface, which is automating script, but something eludes the solution.
But if i get the data, from cmd prompt, it will be safe.
i am just using telent to know about the router status.what is the $sign, shows, when you press the enter key after the pw.
Is it a kind of access the router and ready for output, if you issue commands
there is much more than i expect that it needs to be done .
there are few software, like router statistics software, but it will only work, if you send your router id and everything to the developer .so many router would be there in the market and finding everything tough, i came to this forum hopring to get solution .
please modify and also tell me about environmental variab les settings with regard to this project

jraju
Posts: 8
Joined: 27 Jan 2019 05:44

Re: could anybody help with dos commands for this task

#14 Post by jraju » 01 Feb 2019 20:27

hi, penpen,i also do not know how to edit the post. when i changed the path to desktop, to actual path of pc for desktop, ofcourse, i got the txt file in desktop, but the resutl was empty. Am i missing something there.Please kindly modify the script and i will try.
Router page statistics, i posted would have been a output of or accessing the routerr page and getting the status in the format that gets the format of result from the ruter page or in other words, it is inside the command console that allows such commands to display by show command.
when i issue commands after authentication, the commands i see is numerous, like dns, dhcp etc. But i only use just show status to get the results.
so, telenet ip , giving access to read the innerside details of router.
\why router vendors are not making any software to easily read the status, mainly the download speed and upload speed.
Most programs do contain dwn and upstram speed , but only on browsing activity and not the speed shown on operational live at different point of times.
so, i want a kind of monitoring the dsl m;ode and speed. thats all
thanks penpen for giving me more thoughts and expecting your code.i will try and give you the feedback for any correction.
Probably show stauus was a allowed command for my router, and this may be different terminology for different routers

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

Re: could anybody help with dos commands for this task

#15 Post by Squashman » 02 Feb 2019 11:41

If you are trying to automate a telnet connection I would advise you to use Albert Yale's Telnet scripting tool.

http://support.moonpoint.com/downloads/ ... /tst10.php

Post Reply