Find the answer to your Linux question:
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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???

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,422
    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.

  3. #3
    Linux Enthusiast
    Join Date
    Apr 2004
    Location
    UK
    Posts
    682
    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 on
    To be good, you must first be bad. "Newbie" is a rank, not a slight.

  4. $spacer_open
    $spacer_close
  5. #4
    Just 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?????????

  6. #5
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,422
    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.

  7. #6
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4
    Quote Originally Posted by Irithori View Post
    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..)
    I am running windows and I have access to a linux server via telnet. I want to write a windows batch file which should logon to the linux server and execute a particular command.

  8. #7
    Linux Enthusiast
    Join Date
    Apr 2004
    Location
    UK
    Posts
    682
    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.

  9. #8
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,134
    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.

  10. #9
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,696
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •