Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: telnet batch file  (Read 9297 times)

0 Members and 1 Guest are viewing this topic.

abc

  • Guest
telnet batch file
« on: June 21, 2006, 01:56:50 AM »
Hi


abc

  • Guest
Re: telnet batch file
« Reply #1 on: June 21, 2006, 02:01:27 AM »
Hi ALL
  I need help regarding a batch file through which I telnet and run some application if telnet is successful.

  Thankx in advance.

ghostdog74



    Specialist

    Thanked: 27
    Re: telnet batch file
    « Reply #2 on: June 21, 2006, 04:03:24 AM »
    windows telnet have limited facility for scripting. its either you download tools from internet that can do this, or write your own using languages like perl, python,java , vbscript...etc.
    « Last Edit: June 21, 2006, 04:04:10 AM by ghostdog74 »

    abc

    • Guest
    Re: telnet batch file
    « Reply #3 on: June 21, 2006, 05:37:55 AM »
    Thanks ghost

    can U give me a sample perl script to do the same so that I can go through it.

    ghostdog74



      Specialist

      Thanked: 27
      Re: telnet batch file
      « Reply #4 on: June 21, 2006, 07:14:02 AM »
      Google is your best friend.. type "Net::Telnet examples" in google. Go for the first result,  it shows examples on how to use the module

      abc

      • Guest
      Re: telnet batch file
      « Reply #5 on: June 21, 2006, 09:18:01 AM »
      Thankx ghost

        I need to clarify 2 more things

      1.   I am doing telnet thru the batch file and interactively typing the user name and password and I need to test the status code of telnet command then execcute another command if successful. How to achieve this? I will write the algorithm below:
                     telnet <hostname>
                     if telnet is SUCCESSFUL
                             execute command
                     else
                             EXIT

      2. Is it possibe to trap ctrl-D character in batch file.

      ghostdog74



        Specialist

        Thanked: 27
        Re: telnet batch file
        « Reply #6 on: June 21, 2006, 09:45:24 AM »
        Quote
        Thankx ghost

          I need to clarify 2 more things

        1.   I am doing telnet thru the batch file and interactively typing the user name and password and I need to test the status code of telnet command then execcute another command if successful. How to achieve this? I will write the algorithm below:
                       telnet <hostname>
                       if telnet is SUCCESSFUL
                               execute command
                       else
                               EXIT

        2. Is it possibe to trap ctrl-D character in batch file.


        1) don't get you. A batch file's purpose is for automation. If you want to do it interactively, just open a command prompt and type telnet <hostname> will do. And, by doing interactive,  your eyes will do the error checking whether its succesful...right?
        2) it is beyond simple batch to catch keyboard characters, AFAIK. Maybe some assembly code and feeding these code into debug can do the trick..but it's out of scope for me..