- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: setting environment
Categories
Company
Local Language
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
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
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
тАО01-28-2009 01:30 AM
тАО01-28-2009 01:30 AM
i have written a script with following contents and script name is "env". I actualy want my environment to be set when i execut his script.
#!/sbin/sh
export ORACLE_BASE=/oracle
expoer ORACLE_HOME=$ORACL_BASE/product/bin
on prompt, i execute ". env", it returns me error mesage
su:Syntex error: '(' is not expected.
What is the problem an how to resolve it?
Thanks
Salman
Solved! Go to Solution.
- Tags:
- environment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 01:32 AM
тАО01-28-2009 01:32 AM
Re: setting environment
double quote your long strings. ORACLE_HOME
Change"
export ORACLE_HOME=$ORACL_BASE/product/bin
to:
export ORACLE_HOME="${ORACL_BASE}/product/bin"
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
тАО01-28-2009 01:43 AM
тАО01-28-2009 01:43 AM
Re: setting environment
# export ORACLE_BASE=/oracle
# export ORACLE_HOME=$ORACLE_BASE/product/bin
# echo $ORACLE_BASE
/oracle
# echo $ORACLE_HOME
/oracle/product/bin
# echo $SHELL
/sbin/sh
Are you sure you typed correctly?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 02:09 AM
тАО01-28-2009 02:09 AM
Re: setting environment
You do:
# . env
sh: Syntax error: `(' is not expected.
No, you want,simply:
# env
You can redirect the output into a file:
# env > myenv
...or capture it in a variable to parse later:
# MYENV=$(env)
# echo ${MYENV}
...
If you preceed the above with:
# export ORACLE_BASE-/oracle
...then you will see that too when you query your current environment.
Regards!
...JRF...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 02:15 AM
тАО01-28-2009 02:15 AM
Re: setting environment
I folowed your instructions but problem and error message is same
Venkatesh, if i write it on shell prompt, it works fine, but i want to write a script file so that when i execute it in my shell, it set all envirnoments.
Thanks
Salman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 02:18 AM
тАО01-28-2009 02:18 AM
Re: setting environment
Thanks for your reply. i am a bit new in HP Unix, the thing i am doing works fine with Linux. I didn't get what you what ou want me to do.
I simpley want to set 4 environment variabes to be set when i execute a script file. I would appreciate if you could tell me how to do this in a simple way.
I would need a few diffirent scripts files to set my environment for different versions of oracle.
Thanks
Salman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 02:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 02:31 AM
тАО01-28-2009 02:31 AM
Re: setting environment
You wrote:
#!/sbin/sh
export ORACLE_BASE=/oracle
expoer ORACLE_HOME=$ORACL_BASE/product/bin
on prompt, i execute ". env", it returns me error mesage
As I said, to declare and export variables into your environment do:
#!/sbin/sh
export ORACLE_BASE=/oracle
...That is correct and you can see this in your current environment with:
# env
...Notice that you don't issue '. env' only 'env' at the prompt.
NOW, if you want one shell script to pass environmental variables into another shell script, do this:
# cat myenv
#!/usr/bin/sh
YOU=Shalman
ME=JRF
WHERE="at work"
...This declares variables you want to pass around in your environment.
# cat myscript
#!/usr/bin/sh
. ./myenv
echo "I am ${ME} and you are ${YOU} and we are ${WHERE}"
...Notice the dot-space-filename used to source (or read) the file './myenv'. This means that the shell (your script, 'myscript' doesn't run './myenv' but rather reads it into your _current_ environment. Now, when you excute:
# ./myscript
I am JRF and you are Shalman and we are at work
...is displayed.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 02:34 AM
тАО01-28-2009 02:34 AM
Re: setting environment
My apologies for writing:
YOU=Shalman
...I should have written:
YOU=Salman
...in the 'myenv' variables :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-28-2009 04:40 AM
тАО01-28-2009 04:40 AM
Re: setting environment
Thank you very much all.
It works same like Linux :)
Only mistake i was making was to name my script "env". I have changed its name to "abc" and it is working fine
Thanks any way
Salman