How can I automate the following process?
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: How can I automate the following process?

  1. #1
    Senior Member
    Join Date
    Aug 2003
    Posts
    205

    How can I automate the following process?

    Hello all,

    This maybe simple request to many of you...unfortunately my forte is not in scripting/[programming..

    I am currently working with network engineering group where I have to from time to time telnet to a unix server and run a script to get the password of network devices on the network...

    However, before I can get the password of a device, I have to cd to a directory run the script and enter several passwords.

    It is some what tedious to manually perform the proccess. I was wondering if I can automate through a batch file or maybe VB. Any recommendations appreciated.

    Thnx in advance...




    This is exactly what I have to do, to get the password of a network device (lets call it hostname)

    1. telnet to x.x.x.x <enter>

    2. enter username <enter>

    3. enter passwd <enter>

    4. cd /a/b/c <enter>

    5. run the script Cget.pl "hostname" <enter>

    6. enter userID <enter>

    7. enter password2 <enter>

    8. enter userID1 <enter>

    9. enter mypass3 <enter>


    Thanks again
    I hope I made myself clear..


    P.S.
    I want to be able to run the script/program where I can enter a different hostname each time.( hostname I guess would be a variable)..

  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Script the entire process in Perl. Shouldn't be to hard to do. Use Net::Telnet and go from there.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    rebmeM roineS enilnOitnA steve.milner's Avatar
    Join Date
    Jul 2003
    Posts
    1,018
    I dunno if this would work but try -

    telnet 1.2.3.4 < commands.txt

    where commands.txt looks like this:
    username
    password
    cd /a/b/c
    Cget.pl "hostname"
    userID
    password2
    userid1
    password3
    quit


    If that works I can easily show you a shell/batch script that takes two text files made up of the first half of the commands.txt, adds a userdefind "hostname" and then the seccond half and executes the telnet command.

    Let me know if the commands.txt works at all.

    Steve
    IT, e-commerce, Retail, Programme & Project Management, EPoS, Supply Chain and Logistic Services. Yorkshire. http://www.bigi.uk.com

  4. #4
    Senior Member
    Join Date
    Aug 2003
    Posts
    205
    Steve,
    Ill try it and let you know...

    SirDice,
    If I did it in Perl I will no0t be able to execute it..not allowed to install Perl on PC...

    Thnx..

  5. #5
    Senior Member
    Join Date
    Aug 2003
    Posts
    205
    Steve,

    It didnt work..

    I telnetted and then quickly it gave me prompt

    Welcome to microsoft telent client
    Escape Character is 'CTRL+]'


    I dont know if it matters, but when I enter the passwords manually, there is like a 2-3 second pause before I am promted for the next step.....

  6. #6
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    Yeah I have tried this type of thing. It seems that any telnet or ssh you try the script will stop at the user and password prompt no matter what and you have to enter it. I don't think there is a was around it. You could have a script at the place you telnet to and run it from there though.

  7. #7
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    Look into expect

    User Commands EXPECT(1)

    NAME
    expect - programmed dialogue with interactive programs, Ver-
    sion 5

    SYNOPSIS
    expect [ -dDinN ] [ -c cmds ] [ -[f|b] ] cmdfile ] [ args ]

    INTRODUCTION
    Expect is a program that "talks" to other interactive pro-
    grams according to a script. Following the script, Expect
    knows what can be expected from a program and what the
    correct response should be. An interpreted language pro-
    vides branching and high-level control structures to direct
    the dialogue. In addition, the user can take control and
    interact directly when desired, afterward returning control
    to the script.

    Expectk is a mixture of Expect and Tk. It behaves just like
    Expect and Tk's wish. Expect can also be used directly in C
    or C++ (that is, without Tcl). See libexpect(3).

    The name "Expect" comes from the idea of send/expect
    sequences popularized by uucp, kermit and other modem con-
    trol programs. However unlike uucp, Expect is generalized
    so that it can be run as a user-level command with any pro-
    gram and task in mind. Expect can actually talk to several
    programs at the same time.
    Teams tailor made for that type of situation...

    /nebulus
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  8. #8
    Senior Member
    Join Date
    Aug 2003
    Posts
    205
    thnx for the responses....

    Ill look into expect...
    I was hoping there was a way/tweek through batch...


  9. #9
    rebmeM roineS enilnOitnA steve.milner's Avatar
    Join Date
    Jul 2003
    Posts
    1,018
    Originally posted here by gunit0072003
    Steve,

    It didnt work..

    I telnetted and then quickly it gave me prompt

    Welcome to microsoft telent client
    Escape Character is 'CTRL+]'


    I dont know if it matters, but when I enter the passwords manually, there is like a 2-3 second pause before I am promted for the next step.....
    Sorry.

    Further searching has only revelaed expect.

    Steve
    IT, e-commerce, Retail, Programme & Project Management, EPoS, Supply Chain and Logistic Services. Yorkshire. http://www.bigi.uk.com

  10. #10
    rebmeM roineS enilnOitnA steve.milner's Avatar
    Join Date
    Jul 2003
    Posts
    1,018
    You got any cash to throw at this project - Reflections for windows comes with a scriptable telnet client -

    www.wrq.com

    Steve
    IT, e-commerce, Retail, Programme & Project Management, EPoS, Supply Chain and Logistic Services. Yorkshire. http://www.bigi.uk.com

Posting Permissions

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