switching environments in scripts

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

cgjoker

Thread Starter
Joined
Aug 13, 2003
Messages
205
Okay, here is the situation.

I have a unix program running under one id, my own, (user). In my .profile for user I have placed the following:

myvar=$(cat /Test/user_file.dat)
export user=${myvar%%/*}
export user_pswd=${myvar##*/}

in the file user_file.dat:
user/password

Now I have an application that runs under root.

1. What is happening is that a script that is run by root executes this application. The script that executes this application includes my user and user_pswd in the script so that the application process appears as my own process and not as root.

2. This application in turn will execute another script. In this second script I also include user and user_pswd but it doesn't take. The user and user_pswd lose their values because the application itself is running under root.

So, the question is, how do I pick up the environment variables in my .profile in all my proceeding scripts?

thanks,cg.
 
Joined
Feb 11, 2002
Messages
1,405
I'm not sure I understand all that you've said.

So, the question is, how do I pick up the environment variables in my .profile in all my proceeding scripts?
If you export shell variables, they are available in any subsequent child process (the child process does not have to use them, however).

The script that executes this application includes my user and user_pswd in the script so that the application process appears as my own process and not as root.
Does this mean that when you do a ps -ef listing, the application process is owned by your ID and not by root? How did you determine that the owner of the application process is your ID?

The user and user_pswd lose their values because the application itself is running under root.
This appears to contradict what you said previously ("the application process appears as my own process and not as root".).

In general, environment variables do not lose their values, and child processes cannot affect the evironment of the parent process(es).

Hope this helps. Additional info appreciated.
 

cgjoker

Thread Starter
Joined
Aug 13, 2003
Messages
205
Hmm... I know what your saying. I think im going to have to work with the application vendor in trying to figure out the best way to resolve my dilemma.

Thanks for your help though.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top