- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Using su command from a script
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 09:40 PM
11-21-2005 09:40 PM
Using su command from a script
I'd like to know how we can use the su command thro a script.......any syntax...
thank you.
Robs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 09:46 PM
11-21-2005 09:46 PM
Re: Using su command from a script
Several ways to do it.
su - username -c "commandline"
That is a very common way for a root cron or startup job to become user username and execute whats between the quotes using that users environment.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 09:46 PM
11-21-2005 09:46 PM
Re: Using su command from a script
example of the command we use in a rc2.d start oracle script
su - oracle -c /app/oracle/admin/bin/server_start
Best regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 09:53 PM
11-21-2005 09:53 PM
Re: Using su command from a script
Thank you for the replies....
trying to execute multiple commands using the su ...
e.g,
su - user1 -c "ksh"
and then i need to run a script or command under this shell like,
my startup scripts or commands.....
Thank you once again.
Regards,
Robs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 10:44 PM
11-21-2005 10:44 PM
Re: Using su command from a script
ksh
script
Then exucute
su - user1 -c "suscript"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2005 10:52 PM
11-21-2005 10:52 PM
Re: Using su command from a script
If u want to run a script with name "script1.sh" with oracle id , you can use
su - oracle -c "/home/oracle/script1.sh
Regards
CS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 08:52 PM
11-22-2005 08:52 PM
Re: Using su command from a script
Thank you once again for the help.
Robs