I'm trying to create a directory if it does not exist, and the further down the line, create a log file in that directory. It would be in the current users home directory
In pseudocode:
If directory "/home/LOGS" does not exist
make directory "/home/LOGS"
Then whenever a log file is created, it will save in that directory, not the directory that the program is being run from.
This is what I have so far, and it's just not working...
pushd -n $"../LOGS" >/dev/null 2>&1
#Create the logs folder
if [ ! -d $"home/LOGS" ]; then
mkdir -p $"home/LOGS"
fi
If it helps, my files are being saved like so:
function savefile {
# Save to file
if [ -e $username.log ]; then
echo "Username already exists, returning you to the menu."
sleep 2
clear
menu
else
echo $fullname >> $username.log
echo $password >> $username.log
curdate=$(date +'%d/%m/%Y %H:%M:%S')
echo $curdate >> $username.log
echo "Creating your account"
sleep 2
clear
echo "Account created"
echo
afterBasic
fi
}
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire