- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help with su cmd in a shell script
Operating System - HP-UX
1752489
Members
5558
Online
108788
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО05-05-2005 03:38 PM
тАО05-05-2005 03:38 PM
Aloha Sharp HP Folks,
I have written a very simple & basic shell script which I hope will allow me to cron my Oracle 9i startup (and shutdown) times. When I run these commands as root from within the root's shell manually, they work just fine. But when I run the very same commands in the root context from within my simple shell script below, it seems to get "stuck" on the su - oracle command and everything breaks down from there. My shell script will just wait in my Oracle home dir, and when I exit out from su, the shell script continues processing with the . .profile line but the dbstart is useless without the Oracle home environment parameters. Is there something I am missing with trying to su from within a shell script? My OS is HP-UX 11.0. Thanks in advance for anyone who can help steer me in the right direction with this.
Very Respectfully,
Chris Elmore
x----------x cut here x----------x
clear
cd /
su - oracle
. .profile
dbstart
mailx -s"Oracle 9i has started!" user@email.com < /export/chris/oracle_startup.txt
I have written a very simple & basic shell script which I hope will allow me to cron my Oracle 9i startup (and shutdown) times. When I run these commands as root from within the root's shell manually, they work just fine. But when I run the very same commands in the root context from within my simple shell script below, it seems to get "stuck" on the su - oracle command and everything breaks down from there. My shell script will just wait in my Oracle home dir, and when I exit out from su, the shell script continues processing with the . .profile line but the dbstart is useless without the Oracle home environment parameters. Is there something I am missing with trying to su from within a shell script? My OS is HP-UX 11.0. Thanks in advance for anyone who can help steer me in the right direction with this.
Very Respectfully,
Chris Elmore
x----------x cut here x----------x
clear
cd /
su - oracle
. .profile
dbstart
mailx -s"Oracle 9i has started!" user@email.com < /export/chris/oracle_startup.txt
"Life is love and love is life"
Solved! Go to Solution.
- Tags:
- su
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2005 03:55 PM
тАО05-05-2005 03:55 PM
Solution
You ned to do this:
/usr/bin/su - oracle -c "oracle command line"
This gets you the environment and issues the command within the double quotes.
Thats how we do what you wish to do.
SEP
/usr/bin/su - oracle -c "oracle command line"
This gets you the environment and issues the command within the double quotes.
Thats how we do what you wish to do.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
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
тАО05-05-2005 04:25 PM
тАО05-05-2005 04:25 PM
Re: Need help with su cmd in a shell script
Hi
In general, the script that you want to su another user and execute a command is:
su - -c
For example: If you want to execute a script or command like: /home/oracle/script/check_pef.sh
Then the command:
su - oracle -c "sh /home/oracle/script/check_pef.sh"
Do you realy want to make script file? Give me your email, I have script to shutdown and start Oracle database and it is running now in my system....but for Oracle 8i.
Regard,
HoangChiCong
In general, the script that you want to su another user and execute a command is:
su -
For example: If you want to execute a script or command like: /home/oracle/script/check_pef.sh
Then the command:
su - oracle -c "sh /home/oracle/script/check_pef.sh"
Do you realy want to make script file? Give me your email, I have script to shutdown and start Oracle database and it is running now in my system....but for Oracle 8i.
Regard,
HoangChiCong
Looking for a special chance.......
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2005 06:44 AM
тАО05-06-2005 06:44 AM
Re: Need help with su cmd in a shell script
Aloha Folks,
You are the best. That switch was exactly what I needed. I tested the script and it works now. Oracle 9i has a dbstart and dbshut script that automates the startup and shutdown of Oracle and Listener respectively, and the only catch was to get it to run under cron within the Oracle login context. You gave me the tool I needed to make that happen. Again, I really appreciate you sharing your expertise. Take care.
Very Respectfully,
Chris Elmore
You are the best. That switch was exactly what I needed. I tested the script and it works now. Oracle 9i has a dbstart and dbshut script that automates the startup and shutdown of Oracle and Listener respectively, and the only catch was to get it to run under cron within the Oracle login context. You gave me the tool I needed to make that happen. Again, I really appreciate you sharing your expertise. Take care.
Very Respectfully,
Chris Elmore
"Life is love and love is life"
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP