Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    19

    Question Unanswered: shell script from other user with same host

    Hi ,

    I want to run some script from other user and print the output .
    As for example . I am in host pdcdev0001 and with user gen001
    and running some script . from this script i want to go to some other
    user like neg002 and run some script and print the output from the
    original user gen001 .

    Usually we are switching from one user to other by become .

    Please help me out in this regard .
    It's a PRODUCTION issue so very very urgent .

    Manash
    Manash Ranjan

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Code:
    su - neg002 -c "script" > logfile
    Jean-Pierre.

  3. #3
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    19
    Hi ,

    gen001 is not a super user . I tried to run this the error is coming like

    Password:
    su: Sorry


    Could you please write in detail .

    Thanks
    Manash Ranjan

  4. #4
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    As you are not root you need the password of the account to which you want to su, or the account must not have password.
    Jean-Pierre.

  5. #5
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    19
    Hi Aigles ,

    The problem is that i shouldn't show the password in the script as it is very critical because i am in production server . Any other alternative
    to hide password ?

    Thanks
    Manash Ranjan

  6. #6
    Join Date
    Feb 2004
    Posts
    17
    You could give gen001 sudo permission to run
    Code:
    su - neg002 -c "script" > logfile
    As he can run this one command as root when typing
    Code:
    sudo su - neg002 -c "script" > logfile
    he is not prompted for a password. There's a ton of examples on how to achieve it in /etc/sudoers and man sudo/man sudoers I think.
    Last edited by S_Scheible; 02-18-04 at 06:03.

  7. #7
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    19
    Again it is asking for password . My problem is that i don't want to show password in my script . Please help me out . I am using SUN SOLARIS Unix .
    Manash Ranjan

  8. #8
    Join Date
    Feb 2004
    Posts
    17
    Can you post your line in /etc/sudoers for the command?

  9. #9
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    19
    In /etc there is no file called sudoers so where should i post .
    Please reply describing what to do and where to post
    Manash Ranjan

  10. #10
    Join Date
    Feb 2004
    Posts
    17
    Hmm are you sure you have 'sudo' installed? I am not sure where the config file is located on Solaris, it is /etc/sudoers for many flavors of Linux.
    Last edited by S_Scheible; 02-18-04 at 09:00.

  11. #11
    Join Date
    Sep 2003
    Posts
    71
    try creating a file ".netrc" in your home directory with permission 400.

    format of .netrc file woule be
    ============================================
    machine hostname_here login loginid_here password password_here
    =============================================

    add asmany as hostname entries in this file
    field 1,3,5 are reserve word
    field 2,4,6 are variables

  12. #12
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    19
    yes, i made .netrc in the home directory where the original script resides now how to run the shell script from another user where
    i wants to run the script and take the output ????
    Manash Ranjan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •