Pass the password to su in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pass the password to su in shell script
# 1  
Old 01-12-2016
Pass the password to su in shell script

Hello,

I am using below command but this is asking for tty

Code:
c42dba {/home/oracle}: echo sersnp |  su -c  ggs
standard in must be a tty


Best regards,
Vishal
# 2  
Old 01-12-2016
How about :
Code:
su - <user> -c <command>

As for passing password, you will need to use expect or use sudo.
With sudo the syntax is a bit different.

Hope that helps
Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
# 3  
Old 01-20-2016
The sudo tool is designed to give you the choice. It is probably the best way.

Incidentally, you should not really try to force the password in like this. If you have a process to run that is automated, i.e. you don't fire it off as a real person on the command line, then you should really run it as a non-personal account. You can then give that account the sudo privilege to not require a password.

The problem is that if you script this, then anyone able to read your script will know the account password. Additionally, good practice would have you changing the passwords regularly and that might require editing every script each time.

How far have you got with this now?


Kind regards,
Robin
This User Gave Thanks to rbatte1 For This Post:
# 4  
Old 01-20-2016
It is possible on a lot of systems to create an account that will login without requiring a password. DO NOT fall into that trap. @peasant and @rbatte1 gave you sound advice, consider that doing anything else defeats system security.
These 2 Users Gave Thanks to jim mcnamara For This Post:
# 5  
Old 01-26-2016
We have been doing this using OEM(oracle monitoring tool) .There we can login to each target(host) in the group with ggs user
Here my main target was to first login with oracle user and see if that's a goldengate server(with various customized script under oracle user in all servers) if not then exit out of loop so I was looking to su to ggs from oracle user if that's a golden gate.

Then,we thought that if the server won't be goldengate then ggs user also won't exist which would happen in 99% cases.

Sorry,I am putting more terms as oracle specific.


Best regards,
Vishal
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

5. Shell Programming and Scripting

How to use 'expect' to pass UID & Password to a "for loop" in shell script?

Friends, Need someone's help in helping me with the below requirement for a script: > For a list of servers(over 100+), I need to login into each of them(cannot configure password-less ssh) & grab few configuration details < I know, this is possible through expect programming in a simple... (14 Replies)
Discussion started by: thisissouvik
14 Replies

6. AIX

How to use 'expect' to pass UID & Password to a "for loop" in shell script?

Friends, Need someone's help in helping me with the below requirement for a script: > For a list of servers(over 100+), I need to login into each of them(cannot configure password-less ssh) & grab few configuration details < I know, this is possible through expect programming in a simple... (2 Replies)
Discussion started by: thisissouvik
2 Replies

7. UNIX for Advanced & Expert Users

How to auto pass password in shell script !

Hi all, I have a simple script to check the CPU, Swap Memory and Hard Disk. But I can auto assign password in the script to automatic run it in crontab. Everytime when I run this script, it require to insert password like the message below : How can I solve this problem ? (2 Replies)
Discussion started by: cafecoc85
2 Replies

8. Shell Programming and Scripting

How to pass decrypted password to script

Hi Everybody, I am trying to write a script (ksh) to connect to oracle db via sqlplus. As I do not want the password to be in plain text, I've tried to use java to encrypt and decrypt it but I am not sure how can I pass the decrypted password to the script. Pls advise. Below is what I would... (1 Reply)
Discussion started by: Nick1971
1 Replies

9. Shell Programming and Scripting

Pass root password through script

I have several clients (over 120) connected to my server. I want to push some patch to all the client using a script which copies the file from the server to a specific path on the client and then installs it. But for installation of the patch, it needs to be done thorough root login on client.... (7 Replies)
Discussion started by: shahdeo
7 Replies

10. Shell Programming and Scripting

Read Oracle Username password SID from single file and pass it to shell

Dear All I am trying to write one shell which will be running through Cron which contain one SQL query. But I want to draw/fetch the Username password and Instance name (required to loging to the database) from one single file to run that SQL query . Also this file contain details of multiple... (2 Replies)
Discussion started by: jhon
2 Replies
Login or Register to Ask a Question