Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Script for database task.

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-12-2017   -   Original Discussion by Maddy123
Maddy123's Unix or Linux Image
Maddy123 Maddy123 is offline
Registered User
 
Join Date: May 2011
Last Activity: 3 August 2017, 8:24 PM EDT
Posts: 133
Thanks: 32
Thanked 1 Time in 1 Post
Script for database task.

Hi,

I need help in creating script for "User password reset in database" by logging into database from linux server and resetting the user password.
Could you please provide the script for this task?


Steps are given below.
1. Login into database from server

Code:
sqlplus maddy/maddy123@DBname

2. Execute the below command in database to reset password.

Code:
alter user maddy identified by new password


Regards,
Maddy

Last edited by rbatte1; 06-13-2017 at 12:51 PM.. Reason: Added CODE tags
Sponsored Links
    #2  
Old Unix and Linux 06-12-2017   -   Original Discussion by Maddy123
RudiC's Unix or Linux Image
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 18 December 2017, 1:15 PM EST
Location: Aachen, Germany
Posts: 11,818
Thanks: 342
Thanked 3,660 Times in 3,358 Posts
Any attempts / ideas / thoughts from your side?
Sponsored Links
    #3  
Old Unix and Linux 06-12-2017   -   Original Discussion by Maddy123
Maddy123's Unix or Linux Image
Maddy123 Maddy123 is offline
Registered User
 
Join Date: May 2011
Last Activity: 3 August 2017, 8:24 PM EDT
Posts: 133
Thanks: 32
Thanked 1 Time in 1 Post
Hi RudiC,

1. Here is the content of script.


Code:
oracle@testserver:~> cat usercreation.sh
echo "Enter the username to create"
  read Username
   echo "enter the password for the user"
    read Password
     echo "Enter the SID "
      read SID
       echo "create user $Username identified by $Password;
        grant connect,resource to $Username;
         exit
          " | sqlplus / as sysdba@$SID



2. This is how I execute the script.


Code:
oracle@testserver:~> ./usercreation.sh
Enter the username to create
maddy                              -- Here I enter the username 
enter the password for the user
maddy123                           --- Here I enter the new password 
Enter the SID
Demo                                --- Here I enter the database name

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jun 12 14:24:56 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
User created.                      --- Here the user got created.

SQL>
Grant succeeded.                   --- Here it grants privileges (connect,resource) to user.

Regards,
Maddy
    #4  
Old Unix and Linux 06-12-2017   -   Original Discussion by Maddy123
RudiC's Unix or Linux Image
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 18 December 2017, 1:15 PM EST
Location: Aachen, Germany
Posts: 11,818
Thanks: 342
Thanked 3,660 Times in 3,358 Posts
OK, that's user creation, not password change. What keeps you from adapting this script to you new requirement?
Sponsored Links
    #5  
Old Unix and Linux 06-12-2017   -   Original Discussion by Maddy123
Maddy123's Unix or Linux Image
Maddy123 Maddy123 is offline
Registered User
 
Join Date: May 2011
Last Activity: 3 August 2017, 8:24 PM EDT
Posts: 133
Thanks: 32
Thanked 1 Time in 1 Post
Hi,

The script works fine in a server where it is created.

What I need is we are maintaining more than 50 Unix servers including hp-ux and linux server and each server has multiple database running in it.

I want to modify the script in such a way for example when I execute the script in server A ( where it is created) , it should be able to access other servers of databases and reset the user password.

Quote:
OK, that's user creation, not password change
The script will create new user, reset the password for user and grant connect,resource privilege to user.
Sponsored Links
    #6  
Old Unix and Linux 06-13-2017   -   Original Discussion by Maddy123
rbatte1's Unix or Linux Image
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 18 December 2017, 12:05 PM EST
Location: Lancashire, UK
Posts: 3,412
Thanks: 1,477
Thanked 669 Times in 602 Posts
If you give it $SID for a remote database, does it connect?

If so, simply wrap your code in a shell loop. It would probably be better if you can read a list of SIDs from a file so you can maintain that more simply than editing the script each time you need to add/remove a SID.


Robin
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Run a task in a script at a particular time vskr72 Shell Programming and Scripting 2 12-30-2013 03:50 PM
Whether Shell script can do this task ??? Akshay Hegde Shell Programming and Scripting 13 12-03-2012 12:44 AM
command task script karthikkasarla Shell Programming and Scripting 4 07-01-2011 06:07 AM
last task for my script dvah Shell Programming and Scripting 4 03-23-2011 02:17 PM
comment and Uncomment single task out of multiple task madhusmita Shell Programming and Scripting 9 06-18-2008 10:42 AM



All times are GMT -4. The time now is 02:37 PM.