How can i invoke SU command in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can i invoke SU command in shell script
# 1  
Old 09-26-2008
How can i invoke SU command in shell script

Hi All ,

i am trying to switch user (from unix1 to unix 2 ) The user will give me the input and also the password . also how can i login into with the password . itried several attempts . no luck


Can any one help on this !!!
# 2  
Old 09-26-2008
You should use sudo for this(security...), since it can be configured in a way that user1 can sudo -su user2 without asking a passwd... and use it in scripts
e.g. of sudoers:
opersad ALL=/usr/bin/su - dbasad -c save_*,...
# 3  
Old 10-03-2008
i tried to use su command and it was able to login to different user .. but there it stops and not able to execute the rest of my shell script ..

any thing you guys can suggest ???
# 4  
Old 10-04-2008
Code:
su -c "echo hi" user

# 5  
Old 10-04-2008
Code :

# su - <new_user> -c "bash script_to_be_executed"

Cheers.....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Invoke a shell script in case mail with a specific subject is received

Hello fellow forum members, I have a script which returns a date (I can design the script to return the value in email), How can I design the script in AIX to invoke another shell script which performs some set of actions. Procmail doesnt work in AIX. (4 Replies)
Discussion started by: ektubbe
4 Replies

2. Shell Programming and Scripting

Problem while Invoke Shell Script function from Java Program

Hi, I have create a Shell Script, with one function. I want to call the script file in Java Program. It working fine. but the problem is the function in the Shell Script is not executed. Please suggest me, Regards, Nanthagopal A (2 Replies)
Discussion started by: nanthagopal
2 Replies

3. Shell Programming and Scripting

invoke this command after every 10 mins

Hi, I have an command which find the files modified within last 3 days and then after selecting the files from the location it make the tar format and send it to the specified destination ...now I want that this task to be automative ..that is it should happen after every 5 minutes ..plz guide me... (5 Replies)
Discussion started by: Neera
5 Replies

4. UNIX for Dummies Questions & Answers

Invoke a shell script on new email in inbox

Hello all, Is there a way I can invoke a shell script when ever a new mail is delivered to my account in solaris? Something like .forward file, instead of forwarding it to another email id, I want the email to be passed onto some shell script. Basically I want to extract the envelop... (3 Replies)
Discussion started by: atukuri
3 Replies

5. Shell Programming and Scripting

Shell script to invoke options automatically

i have a script which has 2 options. a b And a has 6 sub options. i want to write a script which will call the parent script and give options automatically. examle: linasplg11:/opt/ss/kk/01.00/bin # startup.sh /opt/ss/rdm/01.00 Please select the component to... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

6. Shell Programming and Scripting

Invoke shell script in cgi script

Hi, I just tried to call a simple shell script from a cgi script writing in c programming.But,it is not working.i will be grateful if anyone can show me the problems going on as i m new to c and oso shell script.Thanks. -Here is my shell script of call the 'pc shut down' system command in... (1 Reply)
Discussion started by: carolline
1 Replies

7. Shell Programming and Scripting

Shell script to invoke db startup/shutdown

Hi all, I have a shell script which does db shutdown ..the script snippet which does this is as follows: function call_sql_plus { ${SQLPLUS:-sqlplus} -s /nolog <<EOF EXIT; EOF if then echo "Error occurred while calling sqlplus " ... (3 Replies)
Discussion started by: KrishnaSaran
3 Replies

8. UNIX for Dummies Questions & Answers

need to invoke a shell script from xml file.

hi all, forgive me if this question is not relevant to this section. i have a shell file that will automatically deploy the files that are necessary and will compile them. i need to automate this management process through cruise control, for this i need to know whether it is possible for me to... (2 Replies)
Discussion started by: sais
2 Replies

9. Shell Programming and Scripting

Bourne: How to invoke an alias from within a shell script

Bourne: How to invoke an alias from within a shell script If I type in the alias in the command line, it runs If I insert that same alias into my shell script and run the shell script, the alias is not invoked. Help please. (2 Replies)
Discussion started by: techshots
2 Replies

10. Shell Programming and Scripting

how to invoke shell script

hi everybody, i learning unix now only.Can u pls guide me in invoking a shell script.Actually i need to know how to write the command for invoking the shell script.Suppose the shell file name is count , then how i will write the command. thanks (1 Reply)
Discussion started by: gopa_mani
1 Replies
Login or Register to Ask a Question