From ded7002f599fd719e25cca3eccc3dfd8c273fe28 Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Wed, 13 Mar 2013 11:11:57 +0000 Subject: [PATCH] More secure way to prevent conflicts if multiple user execute script on the same system. --- check_modules.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/check_modules.sh b/check_modules.sh index d57b5ec..6708c9b 100755 --- a/check_modules.sh +++ b/check_modules.sh @@ -21,11 +21,12 @@ IRed='\e[0;91m' # Intense Red # intermediate files, logfiles LOGDIR=${LOGDIR:=$PWD} -TMP=${TMP:=/tmp} +tmpdir=/tmp/check_modules-$USER +mkdir -p $tmpdir logfile="$LOGDIR/check_modules.log" # logfile with detailed information -module_load_logfile="$TMP/.module_load.$$.log" # output of 'module load commands -module_rm_logfile="$TMP/.module_rm.$$.log" # output of 'module rm' commands -module_clean_env_file="$TMP/.module_clean_env.$$" # original environment +module_load_logfile="$tmpdir/.module_load.log" # output of 'module load commands +module_rm_logfile="$tmpdir/.module_rm.log" # output of 'module rm' commands +module_clean_env_file="$tmpdir/.module_clean_env" # original environment # safe the original environment set > $module_clean_env_file @@ -105,6 +106,7 @@ done # clean up file storing the initial environment rm -f $module_clean_env_file +rm -rf $tmpdir echo "----------------------------------------"