0

I have the following script here.

#!/bin/bash
#some initial variables
DLURL=https://raw.github.com/horvan/drubuntu/master
DIRURL=/opt/.drubuntu
#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`
.install.sh
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?

2

Use

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

 OR 

export nameofuser=`logname`

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

https://stackoverflow.com/questions/4598001/how-do-you-find-the-original-user-through-multiple-sudo-and-su-commands

| 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.