?
Solved

How to write a telnet script and ask Windows' DOS to execute?

Posted on 2008-11-19
6
Medium Priority
?
11,255 Views
Last Modified: 2013-11-29
How to write a telnet script and ask Windows' DOS to execute?

I want the script to do the following.
telnet
 
open 10.33.000.000
 
login: abc
Password: abc
 
cd /app/mfgpro/data/trng/intf/ex/BILLY
cp -p *.* /app/mfgpro/data/trng/intf/ex/BILLY/arc
 
exit
 
quit

Open in new window

0
Comment
Question by:mawingho
  • 3
  • 3
6 Comments
 
LVL 2

Expert Comment

by:patrickrw
ID: 23000764
You should be able to do this. You will have to put the instructions you want run into a batch file and use a scheduled task to make it run on specified days at specified times. Just save the commands you want run just like you have it now into notepad and then save it as a .bat file. I would save it to C: so its easy to find. Then in your scheduled tasks just make it scheduled to run that .bat file at a certain day/time. Should be all there is to it.

*Note: Telnet is bad security wise. Might want to look at using SSH if at all possible.
0
 

Author Comment

by:mawingho
ID: 23001226
SSH? how to use?
0
 

Author Comment

by:mawingho
ID: 23001241
doesn't work.....when I double click it, it keep showing the same things...seems doing a loop
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Accepted Solution

by:
patrickrw earned 2000 total points
ID: 23001619
It looks like you are connecting to another computer and copying files from one directory to another. I would have to look into how to use SSH to do this.

I've found the problem with the file not running correctly. Instead of making a .bat file it should be a .vbs file. .bat files work for most things but because telnet requires user intervention (i.e. you must type things in and then hit enter to send the command) you must use a .vbs script in order for it to work correctly.

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd"
WScript.Sleep 100
WshShell.AppActivate "C:\Windows\system32\cmd.exe"
WScript.Sleep 100
WshShell.SendKeys "telnet 10.33.000.000{ENTER}"
WScript.Sleep 100
WshShell.SendKeys "abc{ENTER}" 'Username
WshShell.SendKeys "abc{ENTER}" 'Password
WScript.Sleep 100
WshShell.SendKeys "cd /app/mfgpro/data/trng/intf/ex/BILLY{ENTER}" 'repeat as needed
WScript.Sleep 100
WshShell.SendKeys "cp -p *.* /app/mfgpro/data/trng/intf/ex/BILLY/arc{ENTER}" 'repeat as needed
WScript.Sleep 200
WshShell.SendKeys "exit{ENTER}" 'close telnet session'
WScript.Sleep 200
WshShell.SendKeys "{ENTER}" 'get command prompt back
WScript.Sleep 200
WshShell.SendKeys "exit{ENTER}" 'close cmd.exe

If you will copy the above code into notepad and save it as a .vbs file it should run correctly. Remember to make changes to the username and password as needed.
0
 

Author Comment

by:mawingho
ID: 23019690
can you explain WshShell.AppActivate?
0
 
LVL 2

Expert Comment

by:patrickrw
ID: 23021197
WshShell specifies which application to activate or start. The AppActivate returns a boolean value telling it that yes the app was successful in starting or not it was not started.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know how boring and exhausting it is to transfer huge web projects developed locally to a webserver simply via FTP. The File Transfer Protocol is a really nice solution if you need to transfer small amounts of files, but if you're plannin…
SSL is a very common protocol used these days when browsing the web.  The purpose is to provide security to communication, but how does it do it?  There are several pieces at work that have to be setup before SSL will even work and it requires both …
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question