[vox-tech] Inheriting env variables when you do a su

Tim Riley vox-tech@lists.lugod.org
Wed, 23 Apr 2003 12:27:43 -0700


Richard Crawford wrote:

> Tim Riley wrote,
>
> > Sure: export SPIFFY_VAR. Then the -c option is not needed.
>
> So, for example, in my script I'd write,
>
> SPIFFY_VAR=/home/stuff
> export SPIFFY_VAR
> .
> .
> .
> su process_user "{$SPIFFY_VAR}/do/something/cool.exe"
>
> ?

Check this out:
$ SPIFFY_VAR=hello; export SPIFFY_VAR
$ su process_user -c 'env | grep SPIFFY_VAR'

Note, there's a short hand assignment syntax:
$ export SPIFFY_VAR=hello

>
>
> (Pardon the ignorance... Bash scripting is not something I'm at all
> familiar with, and I've suddenly found myself in a job where I'll be doing
> a lot of it -- on a Solaris box, no less.  Yikes.)
>
> --
> Slainte,
> Richard S. Crawford
> AIM: Buffalo2K / Y!: rscrawford / ICQ: 11640404
> http://www.mossroot.com http://www.stonegoose.com
> "It is only with our heart that we can see clearly.  What is essential is
> invisible to the eye."  --Antoine de Saint Exupery
>
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech