Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File to Telnet to UNIX

Status
Not open for further replies.

YerMom

Programmer
Joined
Oct 3, 2006
Messages
127
Location
US
Hello,

I need to create a batch file to telnet to a unix machine. An essential requirement is to supply my user name and password in the batch file so that the telnet process will not prompt me.

I've been able to supply the machine name and user name like so:

Code:
telnet <machine> -l<user>
where <machine> is the unix machine name I want and <user> is my user ID.

But I've not been able to put my password in there. Can this be done?

Thanks...
 
It does not apear to be possible with the windows telnet client.
 
smah,

Thanks for your confirmation.
 
You can do it with vbscript. This is similar to using expect on Unix

1) Give the dos window a title like UNIXTelnet.
2) Create a vbscript that creates an application shell
3) The password can be sent using the sendkeys method

Alternatively, there is a really neat method if you can use ftp. Have a look at
 
Thanks xwb!

I've never done vbscript before. Do you have any hits or code snippets?

Don't tell me too much or I won't learn much.

Thanks.
Steve
 
Putting a password in a clear text is not a good practice!

Have you ever heard of ssh (secure shell)? You can install the ssh client on your PC and configure it to access your unix box without prompting for a password (using private keys)

I have the concept but unfortunatly i was trying to do this on one of my windows servers but i haven't managed to do so yet.

Regards,
Khalid
 
Have you tried the tinyapps version? It uses ftp instead of telnet. I think that's a lot neater since what you want to do is transfer a file.

We use commercial ssh on our servers and we've got no end of problems. Copying files to and fro is fine. Executing commands isn't. We've had all sorts of problems from not getting the correct return codes to commands not executing at all!

Send keys example plus 151 ways of doing all sorts of stuff with vbscript
 
xwb,

Because of schedules I've not had time to investigate tinyapps. As a stop-gap measure, I'm sticking
Code:
telnet -l<user name>
and entering my password when prompted.

I'm an automation/programming freak and wish I had time to investigate tinyapps as well as the computerperformance web site. I'll bookmark them for the mythical day when things lighten up.

khalidaaa,
thanks for your idea.
 
I'd try it when you have a spare 2 minutes - that's all it takes. It is very easy to understand. Cut the example, change your

domain
username
password
file to be transferred

and that is it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top