Index: /issm/trunk/cron/configs/linux64_morlighem
===================================================================
--- /issm/trunk/cron/configs/linux64_morlighem	(revision 1534)
+++ /issm/trunk/cron/configs/linux64_morlighem	(revision 1535)
@@ -16,5 +16,5 @@
 
 #external pakages to be installed
-EP_LIST="mpich2 petsc metis triangle"
+EXTERNALPACKAGES="mpich2 petsc metis triangle"
 
 #number of cpus
Index: /issm/trunk/cron/configs/macosx32_seroussi
===================================================================
--- /issm/trunk/cron/configs/macosx32_seroussi	(revision 1534)
+++ /issm/trunk/cron/configs/macosx32_seroussi	(revision 1535)
@@ -15,5 +15,5 @@
 
 #external pakages to be installed
-EP_LIST="mpich2 petsc metis triangle"
+EXTERNALPACKAGES="mpich2 petsc metis triangle"
 
 #number of cpus
Index: /issm/trunk/cron/nightlyrun.sh
===================================================================
--- /issm/trunk/cron/nightlyrun.sh	(revision 1534)
+++ /issm/trunk/cron/nightlyrun.sh	(revision 1535)
@@ -9,4 +9,5 @@
 else
 	echo "no config file specified. Exiting..."
+	exit 1
 fi
 
@@ -29,14 +30,8 @@
 cd $ISSM_DIR/etc
 
-#modify MATLAB_PATH ( /usr/...   ->   \/usr\/...)
-echo $MATLAB_PATH | sed 's/\//\\\//g' > MATLAB_PATH2
-MATLAB_PATH2=`cat MATLAB_PATH2`
-rm MATLAB_PATH2
+#source environment variables with new matlab path
+source environment.sh MATLAB_DIR=$MATLAB_PATH
 
-#modify MATLAB_DIR in environment_variables.sh
-cat environment_variables.sh | sed -e "s/C:\/MATLAB\/R2009a\//$MATLAB_PATH2/g" > environment_variables.sh.bak
-mv environment_variables.sh.bak environment_variables.sh
-
-#Create cluster.rc
+#create simpler  cluster.rc file, with only the cluster we are interested in.
 cat << END > cluster.rc
 begin
@@ -46,11 +41,10 @@
 end
 END
-source $ISSM_DIR/etc/environment.sh
 
 #2: install some required external packages
 cd $ISSM_DIR/externalpackages
-for EP in $EP_LIST
+for ep in $EXTERNALPACKAGES
 do 
-	cd $EP
+	cd $ep
 	cp configs/$OS/* .
 	./install.sh $NUMCPUS
Index: /issm/trunk/etc/environment.csh
===================================================================
--- /issm/trunk/etc/environment.csh	(revision 1534)
+++ /issm/trunk/etc/environment.csh	(revision 1535)
@@ -2,4 +2,10 @@
 
 source $ISSM_DIR/etc/environment_variables.csh
+
+#Do we have any command line arguments? (such as MATLAB_DIR=otherdirthandefault), source them before exporting the variables 
+#to environment.
+foreach i ($@)
+eval $i
+end
 
 #MATLAB
Index: /issm/trunk/etc/environment.sh
===================================================================
--- /issm/trunk/etc/environment.sh	(revision 1534)
+++ /issm/trunk/etc/environment.sh	(revision 1535)
@@ -1,4 +1,11 @@
 #ISSM_DIR and ISSM_ARCH should have been defined already in your shell settings file (.bashrc, .cshrc, etc ...)
 source $ISSM_DIR/etc/environment_variables.sh
+
+#Do we have any command line arguments? (such as MATLAB_DIR=otherdirthandefault), source them before exporting the variables 
+#to environment.
+for i in $@
+do
+	eval $i
+done
 
 #MATLAB
Index: /issm/trunk/etc/environment_variables.sh
===================================================================
--- /issm/trunk/etc/environment_variables.sh	(revision 1534)
+++ /issm/trunk/etc/environment_variables.sh	(revision 1535)
@@ -4,5 +4,4 @@
 #
 #
-
 
 #MATLAB
@@ -60,11 +59,4 @@
 YAMS_DIR="$ISSM_DIR/externalpackages/yams/install"
 
-#TEX2IM
-TEX2IM_DIR="$ISSM_DIR/externalpackages/tex2im/install"
-
-
-
-
-
 #Development packages
 #automake
@@ -82,3 +74,2 @@
 #sdk
 SDK_DIR="C:/MicrosoftVisualStudio 9.0/Microsoft Visual C++ 2008 Express Edition with SP1 - ENU"
-
