How to handle command line options after switching the user in script

Discussion in 'Command Line' started by Viswanath Ediga, Feb 14, 2013.

  1. Viswanath Ediga

    Viswanath Ediga New Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hello All,

    I am writing a script where I need to switch to another user in the middle of the script. It goes as below
    Code:
    echo "$HOME"
    echo $1
    id
    sudo su - oradev << \EOF
    echo "$HOME"
    echo $1
    id
    When I run the above script as "sh script_name hello" out put is as below

    Code:
    /home/nagios
    hello
    uid=5003(nagios) gid=5003(nagios) groups=500(dba),5003(nagios)
    /home/oradev
                               <####### I want my command line option,hello, to be echoed here as well 
    uid=544(oradev) gid=500(dba) groups=500(dba)
    our command line option, $1=hello, is working fine before switching the user, but for some reason it is not showing up after switching user.
    I would be really happy if any one has any ideas on how to get this worked.

  2. jasko

    jasko New Member

    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Did you search on google for it?
  3. Viswanath Ediga

    Viswanath Ediga New Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Yes, I did google my problem. I found no luck :(

Share This Page