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

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

mawinghoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

patrickrwCommented:
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
mawinghoAuthor Commented:
SSH? how to use?
0
mawinghoAuthor Commented:
doesn't work.....when I double click it, it keep showing the same things...seems doing a loop
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

patrickrwCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mawinghoAuthor Commented:
can you explain WshShell.AppActivate?
0
patrickrwCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking Protocols

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.