Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: run sub-script as normal user within a script run by root

  1. #11
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,106
    Blog Entries
    2

    Default Re: run sub-script as normal user within a script run by root

    Quote Originally Posted by jcdole View Post
    Thank you for tour answer which is interesting.
    But does not answer my question.
    I think you'll need to re-phrase your question if you're looking for a specific answer to a specific situation.

    My answer suggested two ways to execute your script as a normal User...
    - Start running your script as the logged in User
    - Sudo to the User in your script.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  2. #12
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,031

    Default Re: run sub-script as normal user within a script run by root

    Quote Originally Posted by malcolmlewis View Post
    Hi
    Why not switch to the user to create what ever your doing with your scripts, or why not use profile.d to run them when the user logs in?
    Because this script is use to configure with one-click, any new computer with a minimal common config for everybody.
    This script is run from an usb stick and started with sudo because i am updating some files in /etc, /var, /usr and in '/home/INST' (myself) and in '/home/some_new_user' for the future new user.
    During the execution some task must be run for myself, and for the future user of this new computer.
    So the script is run as root and from time to time some task are run under these two user accounts.
    These tasks are run only once.

    Any comment is welcome
    Thanks for helping. JCD
    __________

    server leap 15-- ASUS g75vw KDE leap 42.3 -- ASUS g750JZ KDE leap 42.3 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  3. #13
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,031

    Default Re: run sub-script as normal user within a script run by root

    I found this on stackoverflow.com

    SUB_CMD=$( printf '%q ' "$SRC_DIR/25-2_create_profile_firefox" 'user_install' )
    CMD="runuser -l user_install -c \"$SUB_CMD\""
    ...
    ...
    ...

    That helps me to pass correctly the parameters when using runuser.

    Any comments are welcome
    Thanks for helping. JCD
    __________

    server leap 15-- ASUS g75vw KDE leap 42.3 -- ASUS g750JZ KDE leap 42.3 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

Page 2 of 2 FirstFirst 12

Posting Permissions

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