The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SuperUser maconte UNIX for Dummies Questions & Answers 0 03-19-2007 01:36 PM
runing a script as superuser bcheaib UNIX for Dummies Questions & Answers 2 07-07-2004 01:24 AM
how to check my hard disk is below 10%, and then send mail to superuser foong Shell Programming and Scripting 3 08-07-2003 11:28 AM
No user able to login except root(superuser) konda UNIX for Advanced & Expert Users 2 06-25-2002 12:19 PM
superuser password change apalex UNIX for Dummies Questions & Answers 4 04-12-2002 11:38 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-28-2008
Sreejith_VK
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
to run sql as superuser

hi All,

In my script I want to run some drop and select statements in the same host as a different user.I am inputting password for the superuser from the user who will be executing the script.

ie ,
Quote:
#!/bin/ksh
echo " \n\n\t Enter the superuser's password:\c"
read pass
I would be greatfull to you experts if you could suggest me how to proceed.
  #2 (permalink)  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Imagine big bold letters here: Don't Do That.

Simply run su - user -c "commands" and su will take care of prompting for the password.

Reading the root password in a userspace script is not recommended.
  #3 (permalink)  
Old 04-28-2008
Sreejith_VK
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Hi ,

Thanks a lot for your reply.
Can you pls site an example also?
I tried reproducing the command but failed.
I was actually trying...

Code:
su - user1 -c "echo 'user123'"
sleep 10
sqlplus "/as systemdba"
select name from v$database; <<+ENDOFSQL+
exit
+ENDOFSQL+
exit
The prompt for password came and the sleep command or echo command is not executed after wards.
The password expected is not root password.
  #4 (permalink)  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You said "superuser password", I assumed root password.

The idea would be 'su - user1 "commands to connect to sql"' -- if it's a long script then just put that in a file and execute that file.
  #5 (permalink)  
Old 04-28-2008
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 499
Like ...

su - user -c "myscript.sh"

And in myscript.sh you'd have something like (perhaps) ...

...
sqlplus /as sysdba @myscript.sql
...

And lastly, in myscript.sql you'd have (or similar) ...

select name from v$database ;

Anyways, hope that helps some

Cheers,
Cameron
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0