Skip to ContentSkip to Footer
Start of content
- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- environment variable is not set when executing scr...
General
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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.
End of content
United States
Hewlett Packard Enterprise International
Communities
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP