Thread: How to change $EUID value to non-zero in the bash shell

  1. #1
    Registered User
    Join Date
    Nov 2016
    Posts
    26

    How to change $EUID value to non-zero in the bash shell

    I have a script(test1.sh) like the below and i need to run it as root because As a prerequisites, we need to install a couple of packages when it enters into this script, value $EUID should be non-zero, Coul you help me to change this $EUID value


    test1.sh
    <code>
    #!/usr/bin/env bash




    ....
    .....


    if [[ $EUID -eq 0 ]]; then
    echo "This script must be run as nonroot user. Otherwise, couple of test cases will fail."
    exit 1
    fi


    .........
    ..........
    .............
    .....


    ..
    .
    .
    .
    .............
    </code>


    Thank you

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,296
    So why can't you do
    sudo test1.sh

    Or within the script itself, for the actual command(s) that need root.
    sudo install
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 10-23-2019, 02:02 PM
  2. Help converting bash shell script to windows
    By chelp123 in forum Tech Board
    Replies: 2
    Last Post: 11-24-2011, 02:22 PM
  3. Cygwin bash shell scripts are not executing.
    By indigo0086 in forum Tech Board
    Replies: 3
    Last Post: 08-01-2007, 07:20 AM
  4. redirect C output to shell (bash) input
    By deltaxfx in forum C Programming
    Replies: 7
    Last Post: 08-24-2005, 01:55 PM
  5. Bash Shell Scripts
    By jennydarma in forum C Programming
    Replies: 1
    Last Post: 12-13-2002, 05:24 AM

Tags for this Thread