|
-
November 20th, 2003, 03:57 PM
#1
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)..
-
November 20th, 2003, 04:02 PM
#2
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.
-
November 20th, 2003, 04:06 PM
#3
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
-
November 20th, 2003, 04:35 PM
#4
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..
-
November 20th, 2003, 04:43 PM
#5
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.....
-
November 20th, 2003, 05:08 PM
#6
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.
-
November 20th, 2003, 05:27 PM
#7
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)
-
November 20th, 2003, 05:58 PM
#8
thnx for the responses....
Ill look into expect...
I was hoping there was a way/tweek through batch...
-
November 20th, 2003, 06:31 PM
#9
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
-
November 20th, 2003, 10:35 PM
#10
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
-
Forum Rules
|
|