Problem with enviroment variables with su - username -c on Solaris 8 - SUN

This is a discussion on Problem with enviroment variables with su - username -c on Solaris 8 - SUN ; Hi all, On a Solaris 8 machine, I'm trying to execute a shell script on an NFS mount which belongs to a user specified in an NIS map. The local shell script that invokes it goes something like this: su ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Problem with enviroment variables with su - username -c on Solaris 8

  1. Problem with enviroment variables with su - username -c on Solaris 8

    Hi all,

    On a Solaris 8 machine, I'm trying to execute a shell script on an NFS
    mount which belongs to a user specified in an NIS map. The local shell
    script that invokes it goes something like this:

    su - theuser -c "/path/to/script" >> logfile > 2>&1 &

    This script at /path/to/script (a bash script) depends on some
    environment variables that belong to 'theuser.' Unfortunately, they
    don't seem to be getting set. The default shell for the user 'theuser'
    is bash, and the home directory is correctly specified.

    Additionally, if I just do 'su -l theuser' I can see all the correct
    environment variables getting set. Following this su by a 'cd,' I go to
    the correct NFS home directory, which I would expect since the
    environment variables were set properly at this point. Just for
    reference, two Linux machines (FC3 and Ubuntu 5.10) happily run this
    command as expected, getting all the proper enviroment variables.

    The Sun man pages claim this should work, but I just can't seem to get
    it to. I'm sure I am missing something simple, but I have run out of
    ideas. Does anyone have any ideas what I may be doing wrong?

    Thanks,
    Joe


  2. Re: Problem with enviroment variables with su - username -c on Solaris 8

    jhosteny@gmail.com wrote:
    >
    > Hi all,
    >
    > On a Solaris 8 machine, I'm trying to execute a shell script on an NFS
    > mount which belongs to a user specified in an NIS map. The local shell
    > script that invokes it goes something like this:
    >
    > su - theuser -c "/path/to/script" >> logfile > 2>&1 &
    >
    > This script at /path/to/script (a bash script) depends on some
    > environment variables that belong to 'theuser.' Unfortunately, they
    > don't seem to be getting set. The default shell for the user 'theuser'
    > is bash, and the home directory is correctly specified.
    >
    > Additionally, if I just do 'su -l theuser' I can see all the correct
    > environment variables getting set. Following this su by a 'cd,' I go to
    > the correct NFS home directory, which I would expect since the
    > environment variables were set properly at this point. Just for
    > reference, two Linux machines (FC3 and Ubuntu 5.10) happily run this
    > command as expected, getting all the proper enviroment variables.
    >
    > The Sun man pages claim this should work, but I just can't seem to get
    > it to. I'm sure I am missing something simple, but I have run out of
    > ideas. Does anyone have any ideas what I may be doing wrong?


    If I do:

    echo xx${PWD}xx${REBUILD}xx ; su - jmh -c 'echo $PWD ; echo $REBUILD'
    &

    I get

    xxxxxx

    /usr/users/jmh
    /export/home2/jmh/install

    which indicates that the command has picked up the right shell for the
    user, is running in my home directory, and that the REBUILD variable
    exclusive to my environment is being set. What happens if you try
    something like that in your case? And what happens if you omit the
    background & at the end?

    John Howells

+ Reply to Thread