I have the following script here.

#some initial variables
#Get files to run the installation
wget -O $DIRURL/install.sh $DLURL/scripts/install/install.sh > /dev/null 2>&1
wget -O $DIRURL/functions.sh $DLURL/scripts/install/functions.sh > /dev/null 2>&1
wget -O $DIRURL/filetemplates.sh $DLURL/scripts/install/filetemplates.sh > /dev/null 2>&1
export nameofuser=`echo $USER`
sudo bash "$DIRURL"/install.sh 2> errors.txt

after execution the value of $nameofuser is not something like username but root.

how to make sure to match the name of the logged in user?



export nameofuser=`who am i | awk '{print $1}'`


export nameofuser=`logname`

as $USER can change if you call the script using sudo, etc.


| improve this answer | |
  • I know that it can change what i want to know is what to do to permitt the variables value from changeing – Josh Dec 25 '14 at 16:00
  • Does that make more sense? – austinian Dec 25 '14 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.