- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- environment variable is not set when executing scr...
Operating System - Linux
1754344
Members
5176
Online
108813
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
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
тАО11-15-2010 11:09 PM
тАО11-15-2010 11:09 PM
environment variable is not set when executing script..
Hi,
i am executing script .script executed successfully. but environment variable is not set...
Sript:
sid1.sh
code:
output:
[oracle@test1 shell]$ sh sid1.ksh
********************************************************************************
The current ORACLE_SID value is testdb
********************************************************************************
The following are valid instance names along with the ORACLE_HOME value:
1 : bingo
2 : +ASM
3 : star
********************************************************************************
Do you want to change ORACLE_SID [Y/N]? \c
y
Enter Slno of the SID from above list : \c
2
Oracle SID: +ASM
[oracle@test1 shell]$ echo $ORACLE_SID
testdb
i am executing script .script executed successfully. but environment variable is not set...
Sript:
sid1.sh
code:
output:
[oracle@test1 shell]$ sh sid1.ksh
********************************************************************************
The current ORACLE_SID value is testdb
********************************************************************************
The following are valid instance names along with the ORACLE_HOME value:
1 : bingo
2 : +ASM
3 : star
********************************************************************************
Do you want to change ORACLE_SID [Y/N]? \c
y
Enter Slno of the SID from above list : \c
2
Oracle SID: +ASM
[oracle@test1 shell]$ echo $ORACLE_SID
testdb
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2010 11:30 PM
тАО11-15-2010 11:30 PM
Re: environment variable is not set when executing script..
Hello.
Source the script if you want to do this:
source sid1.ksh
(using ". sid1.ksh" has the same effect).
Regards,
Goran
Source the script if you want to do this:
source sid1.ksh
(using ". sid1.ksh" has the same effect).
Regards,
Goran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2010 06:22 AM
тАО11-17-2010 06:22 AM
Re: environment variable is not set when executing script..
> [...] environment variable is not set...
Actually, the environment variables _were_
set, but they were set in the wrong process.
> [oracle@test1 shell]$ sh sid1.ksh
> [...]
This runs a shell ("sh"), which runs the
shell script, which runs its own shell
("#!/bin/ksh"), and that "/bin/ksh" process
is where the environment variables were set.
When that process exits, its environment
(with the desired changes) disappears.
> [...] ". sid1.ksh" [...]
That causes the current shell to read the
commands in the file, so that when those
commands set environment variables, the
variables are set in the current shell's
environment, not in some (transient)
sub-shell's environment.
> #!/bin/ksh
A line like this serves no purpose here,
because this is not a complete shell script
-- the current shell must always read
("source") the file (". file"). (Thus, you
couldn't use the same file with a C shell.)
Actually, the environment variables _were_
set, but they were set in the wrong process.
> [oracle@test1 shell]$ sh sid1.ksh
> [...]
This runs a shell ("sh"), which runs the
shell script, which runs its own shell
("#!/bin/ksh"), and that "/bin/ksh" process
is where the environment variables were set.
When that process exits, its environment
(with the desired changes) disappears.
> [...] ". sid1.ksh" [...]
That causes the current shell to read the
commands in the file, so that when those
commands set environment variables, the
variables are set in the current shell's
environment, not in some (transient)
sub-shell's environment.
> #!/bin/ksh
A line like this serves no purpose here,
because this is not a complete shell script
-- the current shell must always read
("source") the file (". file"). (Thus, you
couldn't use the same file with a C shell.)
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