Results 1 to 9 of 9
Hi,
I need to write a windows batch file to run unix commands by logging onto a telnet unix server.
For example , I might want the batch file to ...
- 11-22-2010 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 4
Batch file to run unix commands from windows
Hi,
I need to write a windows batch file to run unix commands by logging onto a telnet unix server.
For example , I might want the batch file to log onto the unix sever, run the ls command, collect the output in a file and ftp it back to my windows desktop.
Is there any way to do it???
- 11-22-2010 #2
Maybe via cygwin, but I flat out refuse to use that beast.

Also, some ssh terminal for windows support logon macros os scripts (and may even speak telnet)
putty itself cannot, but Documentation can atleast execute some commands.
Other than that:
This approach looks quite unstable.
So there is ftp server on your windows machine
and some incremental data on the linux box.
Why not write a cronjob and use lftp to synchronize the local directory to the ftp server?You must always face the curtain with a bow.
- 11-22-2010 #3Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
Hi there,
I think Plink is what you are looking for.
Basically it's a command line version of Putty, a windows ssh-and-other-protocol client, which also covers telnet.
Let us know how you get onTo be good, you must first be bad. "Newbie" is a rank, not a slight.
- 11-22-2010 #4Just Joined!
- Join Date
- Oct 2008
- Posts
- 4
Thanks for the replies........
but I cant use any external software for doing this..........
I have to do it in a windows batch file using built-in windows commands like telnet,ftp,etc..........
Is there any way out?????????
- 11-22-2010 #5
a) telnet is not secure. Passwords are transmitted in cleartext. That alone can -and should- be a roadblock.
My advise would be to use ssh.
b) Please clarify: Does the windows or linux box run a ftp server? (BTW: ftp is also unsecure. But at least one does not get shell access..)You must always face the curtain with a bow.
- 11-23-2010 #6Just Joined!
- Join Date
- Oct 2008
- Posts
- 4
- 11-23-2010 #7Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
Hi there,
I think your problem is with not being able to use extra programs on your windows box. Ssh, as Irithori suggested, actually comes with switches that let you specify a command to be run upon connection (as well as being much more secure).
Do you actually have a telnet client on your windows box?
Let us know how you get on.To be good, you must first be bad. "Newbie" is a rank, not a slight.
- 11-24-2010 #8
It can't be done without a helper program. In UNIX, people
often use expect, but I don't know if that is available
in Windows. The reason it is hard is that, as soon as the telnet
connection is made, the server waits for input from you, but your
batch file is stalled. The next command in the batch file will not execute
until the telnet session is terminated. Catch 22.
- 11-26-2010 #9Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
MS Windows SFU (Services for Unix) has a lot of the tools you need. So, technically you are running Windows tools, and can script them as you need. Anyway, this is not a Windows forum site...

Good luck!Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
