Password change logic for remote machine using shell and expect


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Password change logic for remote machine using shell and expect
# 1  
Old 09-23-2010
Password change logic for remote machine using shell and expect

Day before yesterday,I got the success creating a shell script using expect tool and now it is running successfully on the server.
Now I want to make some changes in paswwordchanger.sh as you can see it can handle only one user i.e dbaguest and not other user.So I am thinking the logic how I can implement.
Corrent script will work in following order:

One ssh.csv file will be generated using below query which needs to be called inside passwordchanger.sh

Code:
SET FEEDBACK OFF
SET LINESIZE 80
SET PAGESIZE 0
SET NEWPAGE 0
SET SPACE 0
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF
SPOOL ssh.csv
Select username||','||ipaddr||','||password  from table where boatid='xyz' and auth='YES';
SPOOL OFF
exit;

(1) It will accept newpassword for dbaguest and it will be stored in a variable i.e paswd.
(2) It will generate a file ssh.csv using boatid where authentication for the user is true.
(3) It will read each line in ssh.csv file and will connect to the host and will change the password with new password what we are passing in step1.
(4) If it fails then it will write it into a log file with ipaddress.

Here I want to make it for other user as well suppose oracle user is there for which I have access but directly I can not login to the server using spawn ssh oracle@ipaddr.
It must login first dbaguest and then su – oracle or other user and then change the password.
For above task I have to play with username variable in passwordchanger.sh with if condition or using case statement.
please suggest me correct line where I can modify and what can be modified.
I appreciate your help.Its a bit urgent.

I am listing my script below which is running successfully:--

Moderator's Comments:
Mod Comment Removed excessive formatting (is it really necessary to format each line on it's own?), added code tags, added meaningful title. Due to multiple cases of this, this user has been temporarily set to "Read Only"

Last edited by manish_1678; 10-13-2010 at 03:08 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can someone please show me a very simple "expect" script to change password in Solaris please?

Ladies & Gents, Can one of you gurus please show me a very simple "expect" script to change the password in Solaris in a script, please? Nothing fancy, no error checking, no nothing. Just to change the password of a new user, it's all. Many thanks in advance. U guys have honestly earned my... (1 Reply)
Discussion started by: Hiroshi
1 Replies

2. Shell Programming and Scripting

Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below: ssh user@hostname 'bash -s'< ./test.sh file.txt But i got the error file.txt doesn't exist. Can anyone help me on this. Content of test.sh: ... (2 Replies)
Discussion started by: manishtri88
2 Replies

3. UNIX for Dummies Questions & Answers

Execute shell script in remote machine

Hi All, We have 2 servers A and B. B is having a sctipt called b.sh in path /home/dev/scripts. Now my requirement is i want to execute b.sh from server A. Kindly help me. (3 Replies)
Discussion started by: Girish19
3 Replies

4. UNIX for Advanced & Expert Users

Unable to run the script on remote machine Using Expect script

Not able to execute the file in remote host using except utility I am automating the SFTP keys setp process: So i created the expect script for controlling the output of shell below is my main code: Code: #!/usr/bin/expect set fd set password close $fd set df set app close $df... (1 Reply)
Discussion started by: Manoj Bajpai
1 Replies

5. UNIX for Dummies Questions & Answers

ssh to remote machine with 2nd user and password

Hi all, Really hope someone can help me, i have been trying lots of things and just cant seem to nail it - and for something that seems straight forward.... Anyway, scenario is I need to log onto a second machine (remote server) from main workstation. Once logged in I need to run a batch... (2 Replies)
Discussion started by: Hopper_no1
2 Replies

6. Shell Programming and Scripting

without password to login into remote machine- in the script ??

HI, I need to write a script .. when I run this script , will directly goto that remote machine without asking password.. Once it is entered, I needs to transfer some of the log files... how can I proceed ? (7 Replies)
Discussion started by: hegdeshashi
7 Replies

7. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

8. Shell Programming and Scripting

Change user on remote machine and execute script!

Hi, I need to login into remote server and execute a shell script over there. As of now i am making use of ssh command ssh primUser@135.254.242.2 sh /poll.sh I am logging in as primUser but unless i change the user to root the script execution on the remote machine is not possible. ... (5 Replies)
Discussion started by: goutham4u
5 Replies

9. Shell Programming and Scripting

change files permission on Remote machine

I would like to change permissions recursively on a remote folder. Seems like sftp has a limitation, I am only able to change permission on a individual file.. sftp > chmod 777 /usr/local/apache/docs/test.txt It would be great if someone has more knowledge on how this is doable recursively? (1 Reply)
Discussion started by: almeisan1
1 Replies

10. Shell Programming and Scripting

Password changing in a Script (shell and expect)

Hi, Does anybody know how to change the password on multiple servers with a script. I have 300 Sun boxes and the password expiry is set to 30 days. Im in a process to build a script using expect. Need a help from an expert who has already done it. Regards, Vinod (1 Reply)
Discussion started by: chellam
1 Replies
Login or Register to Ask a Question