|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Login, excute command, logout Script Help
Good Evening all,
After spending the last week or so reading many posts I decided to register and join in. This is my first post on the forum so please forgive me as im new to this, Im after some help in throwing together a quick basic script without using expect to change the password on several routers. All i need to do is below ssh username@hostname then you will be prompted for a password so the script needs to enter the password. Commands that need entering password change then you will be prompted for current password so script to enter current password you will then be prompted to enter new password so again script to enter then you are requested to confirm the password again. logout then start over again on the next router. unfortunatly i am unable to create password less login either... Any help you guys can offer would be very much appreciated. Thanks Last edited by mutley2202; 01-11-2013 at 05:57 PM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
You cannot easily 'enter a password' with ssh, it is built to bypass most attempts at that.
The passwd command is also that way. You will need to bypass those problems which involves some advanced techniques. What you will have to do is one of these: 1. If you are root or an admin, ssh to the remote box and do password changes one by one manually 2. install the "expect" application and create an expect script to answer all the prompts. You outlawed that already. 3. write a pty emulator in C that can become the sessions leader/terminal owner. see: Solaris Systems Programming download: source code The code you want is called pty.c It is meant for Solaris, but with minor changes it will work on linux. It is basically like expect in that it allows batch interaction with passwords embedded. Which BTW is a terrible idea. Since you have a few routers, this post sat unaswered for a while, maybe you could have completed the task manually. If you want a longterm solution consider #2 or #3. |
| The Following User Says Thank You to jim mcnamara For This Useful Post: | ||
mutley2202 (01-12-2013) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks for your advice much appreciated, this is a task I have to so on a regular basis so will defiantly be looking at my options.
|
|
#4
|
|||
|
|||
|
Consider using/installing (cf.
man )
Quote:
Quote:
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Hi RudiC, Its not allowed due to internal policys unfortunatly.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Login and logout logs in server | kancherla.sree | Solaris | 10 | 07-07-2011 06:29 AM |
| Login/Logout script | tthaler | OS X (Apple) | 3 | 11-23-2009 04:55 PM |
| Login and logout time of a session | sharif | UNIX for Advanced & Expert Users | 1 | 03-10-2008 05:10 AM |
| detecting login or logout | nortypig | Shell Programming and Scripting | 8 | 08-27-2006 08:30 PM |
| Login and logout script | jhansrod | UNIX for Dummies Questions & Answers | 1 | 06-06-2005 06:54 AM |
|
|