- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting
Operating System - HP-UX
1823955
Members
3896
Online
109667
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
Forums
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
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-04-2003 05:30 PM
тАО05-04-2003 05:30 PM
Guru's,
what is the different between :
1)su -c '$ORACLE_HOME/bin/svrmgrl' << EOT
connect internal
startup
exit
EOT
2)su - c "$ORACLE_HOME/bin/svrmgrl << EOT
connect internal
startup
exit
EOT"
when I run 1) I only got :
svrmgrl>
#
It not startup the database at all.
but with 2) is connect and start the database.
any input are appreciate.I have span about 1 day Saturday to rectify this problem.
regards
mB
what is the different between :
1)su -c '$ORACLE_HOME/bin/svrmgrl' << EOT
connect internal
startup
exit
EOT
2)su - c "$ORACLE_HOME/bin/svrmgrl << EOT
connect internal
startup
exit
EOT"
when I run 1) I only got :
svrmgrl>
#
It not startup the database at all.
but with 2) is connect and start the database.
any input are appreciate.I have span about 1 day Saturday to rectify this problem.
regards
mB
There are three person in my team-Me ,myself and I.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2003 05:46 PM
тАО05-04-2003 05:46 PM
Re: scripting
Hi mB,
Your first example switches to the user but without the '-' option the user's .profile and other environment settings aren't executed, so you don't get the normal environment. For the second example, you used the '-' option and got the full environment as if you had logged in as the user. The 'c' option should probably be '-c' which tells the shell to read the commands from the string you passed to it.
This may be what you are after:
su - -c "$ORACLE_HOME/bin/svrmgrl < ...
etc.
JP
Your first example switches to the user but without the '-' option the user's .profile and other environment settings aren't executed, so you don't get the normal environment. For the second example, you used the '-' option and got the full environment as if you had logged in as the user. The 'c' option should probably be '-c' which tells the shell to read the commands from the string you passed to it.
This may be what you are after:
su - -c "$ORACLE_HOME/bin/svrmgrl <
etc.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2003 06:57 PM
тАО05-04-2003 06:57 PM
Solution
I'm sure you can just read the man page for su for a better explaination for the following:
1) not having a username
2) have a - -c or just a -c
i would suppose you left out the username in this case and the - c in #2 is just a typo.
the main difference is with the single quotes (') and the double quotes (").
in #1, the use of the single quotes passes $ORACLE_HOME/bin/svrmgrl to be executed as the command, ie the variable $ORACLE_HOME isn't substituted until after your have changed users. and being the second (') occurs before the <<, the shell creates the heredoc file and opens it as standard input.
in #2, the use of the double quote causes variable subtitution on $ORACLE_HOME to occur before the user is switched, ie the value of $ORACLE_HOME in the current environment will be used instead the the value of $ORACLE_HOME in the new users environment. and the second double quotes occurs at the end of the heredoc, this causes your heredoc to become commandline arguments to svrmgrl instead of becoming a heredoc and read in as standard input. and of course this means #1 works and #2 doesn't.
su user -c 'command' <<
is the same as
su user -c "$command' <<
if in the current environment, $command=command.
su user -c '$command' <<
is the same as
su user -c "\$command" <<
and i'd suspect your wanting to use something like
su - someuser -c '$ORACLE_HOME' << your here doc.
1) not having a username
2) have a - -c or just a -c
i would suppose you left out the username in this case and the - c in #2 is just a typo.
the main difference is with the single quotes (') and the double quotes (").
in #1, the use of the single quotes passes $ORACLE_HOME/bin/svrmgrl to be executed as the command, ie the variable $ORACLE_HOME isn't substituted until after your have changed users. and being the second (') occurs before the <<, the shell creates the heredoc file and opens it as standard input.
in #2, the use of the double quote causes variable subtitution on $ORACLE_HOME to occur before the user is switched, ie the value of $ORACLE_HOME in the current environment will be used instead the the value of $ORACLE_HOME in the new users environment. and the second double quotes occurs at the end of the heredoc, this causes your heredoc to become commandline arguments to svrmgrl instead of becoming a heredoc and read in as standard input. and of course this means #1 works and #2 doesn't.
su user -c 'command' <<
is the same as
su user -c "$command' <<
if in the current environment, $command=command.
su user -c '$command' <<
is the same as
su user -c "\$command" <<
and i'd suspect your wanting to use something like
su - someuser -c '$ORACLE_HOME' << your here doc.
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.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP