- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to provide input from current env to new env
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
Forums
Discussions
Discussions
Discussions
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
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
08-12-2008 02:55 AM
08-12-2008 02:55 AM
how to provide input from current env to new env
Suppose i am executing one script in(/home/XXX).So in that script i am calling another script (For ex:ae_init_sandbox).After running this script(ae_init_sandbox $sandboxname) it is entering into new environment.How to execute another script in the new environment.
ex:
1.sh script--inside script contain ae_init_sandbox $sandboxname
2.ae_init_sandbox(script)
3.It is entering into that particular sandbox(i,e new environment)
4.I want to execute one script in new environmet.
what is the procedure to solve the above cases?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2008 03:09 AM
08-12-2008 03:09 AM
Re: how to provide input from current env to new env
use export command to carry the value to child shell.
Kenan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2008 06:11 AM
08-12-2008 06:11 AM
Re: how to provide input from current env to new env
file "scripta"
----------------------------------
export MYVARA = "hello"
/home/user/scriptb
----------------------------------
file "scriptb"
----------------------------------
echo $MYVARA
----------------------------------
So from the command line if you ran
./scripta from the /home/user directory:
you get "hello" as output
$> ./scripta
hello
If you didn't use "export" first, it wouldn't work. Note that you can export AND declare a variable at the same time in ksh and bash, but not in sh. In sh, in script a you have to do it in two lines like:
MYVARA="hello"
export MYVARA
It's safer to do this the way above, because this always works in bash, ksh, and sh.
Another way to get this done is just pass an argument, and pick it up as $1 in the second script:
file "scriptc"
-------------------------------------------
MYVARC="goodbye"
/home/user/scriptd $MYVARC
----------------------------------------
file "scriptd"
----------------------------------------
echo $1
----------------------------
The run would look like:
$> /home/user/scriptc
goodbye
This is basic stuff, but it sounded to me like this is what you were wanting. If not, please excuse the posting.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2008 06:23 AM
08-12-2008 06:23 AM
Re: how to provide input from current env to new env
Another way to accomplish your goal is to source (read) your variables into your environment from another file. Sourcing (reading) is done by specifying a dot ('.') followed by whitespace, followed by a file to be read:
# cat myscript
#!/usr/bin/sh
WHO=yogesh
echo "I am '${WHO}'"
echo "hi"
. /home/yk/myincl
echo "I am also known as '${NAME}'"
echo "bye"
# cat myincl
#!/usr/bin/sh
NAME=kumar
...run:
# ./myscript
I am 'yogesh'
hi
I am also known as 'kumar'
bye
Note that failure to use the 'dot-whitespace-filename' form will cause a separate environment to be created and you will not have the new environmental variables available.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2008 03:30 AM
08-13-2008 03:30 AM
Re: how to provide input from current env to new env
You're confused. sh IS the posix shell, which is a superset of ksh. Only the bourne shell is junky like that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2008 07:35 AM
08-13-2008 07:35 AM
Re: how to provide input from current env to new env
Thanks.