Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i have to fire some fix set of commands in 1000 routers.
but it's time consuming . i have to login each routers, it gives login and password prompt then have to enter some fix commands.
so dear all i want script that do this fast in linux..
everything enclosed within the ( ) is executed after you telnet into the router
sleep between each command to ensure they dont overlap.
in this example after connected for 3 seconds it will
type/enter a username
Another 3 seconds will type/enter a password
another 5 seconds will run
ping 127.0.0.1
First thanks for giving this logic and it helped me much to write script. but Dear i want to mail after successfully completion of script to xyz@abc.com from command line...
i wrote
[root@tariq ~]# mail -s "Reports are ---" xyz@abc.com < /root/Report
It comes with a nice little expect script called clogin (i think) which handles logging into your cisco kit and issuing a few commands. You can specify username, password, and a ';' delimited list of cisco commands to run against a given router.
It can handle a lot of the awkward stuff quite nicely - i.e. routers with only telnet/enable passwords instead of those with username/password. Also it deals with both CatOS and IOS.
I then wrote a small wrapper perl script to run clogin with given cisco commands against every router listed in a text file.
I am using it but i don't want to exit from telnet session automatically.
what i do?
Acctually i am creating script where i prompt for ip address and then i want to give telnet session automatically for that ip without entering login name and passwd.
Quote:
Originally Posted by carl0ski
I dont remember any Cicso specific commands however this is the basic need
everything enclosed within the ( ) is executed after you telnet into the router
sleep between each command to ensure they dont overlap.
in this example after connected for 3 seconds it will
type/enter a username
Another 3 seconds will type/enter a password
another 5 seconds will run
ping 127.0.0.1
personally i'd strongly suggest using expect to do this. it's a great tool which can do exactly what you're after, albeit in a way that might seem confusing to start with. it's really worth pursuing though if you want to do more things such as this in the future. i use expect to automatically update configs on thousands of cisco routers automatically.
ok sir , i am using expect also but i don't want telnet login prompt and password prompt. i am using this
#!/usr/bin/expect --
set timeout 180
set machine [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
spawn telnet $machine
send "$username\n"
send "$password\n"
interact
now what i do to achieve what i want.....
Quote:
Originally Posted by acid_kewpie
personally i'd strongly suggest using expect to do this. it's a great tool which can do exactly what you're after, albeit in a way that might seem confusing to start with. it's really worth pursuing though if you want to do more things such as this in the future. i use expect to automatically update configs on thousands of cisco routers automatically.
ok dear, but when i run this script, it prompt for username and whatever i enter "that display in terminal" so dear i want to hide username (what i enter) prompt and password prompt and direct want to enter cisco prompt acctualy i am doing telnet to cisco router.
Quote:
Originally Posted by acid_kewpie
well what's not working? all i'd suggest is actually using some expect commands, as you've none there at all, e.g.
dear? what's all this dear nonsense... last few weeks i've been called "dear" a dozen times by different people...
anyway, check the log_user command, which will stop things being echoed to stdout
Code:
log_user -info|0|1
By default, the send/expect dialogue is logged to stdout (and a
logfile if open). The logging to stdout is disabled by the com-
mand "log_user 0" and reenabled by "log_user 1". Logging to the
logfile is unchanged.
dear? what's all this dear nonsense... last few weeks i've been called "dear" a dozen times by different people...
Dear Acid,
I guess its the only "dear" thats troubling you (offlate) & probably "Dear moderator" would be ok in that case.
What you say ?
Btw google reported this for define: dear
Code:
Definitions of dear on the Web:
* beloved: dearly loved
* with or in a close or intimate relationship; "a good friend"; "my sisters and brothers are near and dear"
yeah, using dear as in "dear moderator" isn't the same as using dear as in "thank you dear", "ok dear", etc... personally, i find the latter awkward for a tech support forum, but in the years i've been a member here at LQ i've seen lots of people use the awkward form of dear and i've always just assumed it's a normal way of speaking in a certain part of the world or something... =/
sir, i've got what i want after using "log_user 0" in the script.
thanks a lot to be in touch for last few days.
Quote:
Originally Posted by acid_kewpie
dear? what's all this dear nonsense... last few weeks i've been called "dear" a dozen times by different people...
anyway, check the log_user command, which will stop things being echoed to stdout
Code:
log_user -info|0|1
By default, the send/expect dialogue is logged to stdout (and a
logfile if open). The logging to stdout is disabled by the com-
mand "log_user 0" and reenabled by "log_user 1". Logging to the
logfile is unchanged.
When i run expect script manually as root user from terminal, it's working fine but when it has been called by crond , not giving proper result. What's the problem?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.