Index: trunk/MagicSoft/Mars/datacenter/scripts/scriptlauncher
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/scriptlauncher	(revision 8482)
+++ trunk/MagicSoft/Mars/datacenter/scripts/scriptlauncher	(revision 9122)
@@ -31,7 +31,4 @@
 printprocesslog "INFO starting $0 $@"
 
-makedir $listpath
-makedir $lockpath
-
 errorlog=$runlogpath/scriptlauncher-error`date +%F`.log
 scriptlog=$runlogpath/scriptlauncher`date +%F`.log
@@ -42,24 +39,56 @@
 date=`date +%Y-%m-%d`
 
-scripts=( `echo $@ | sed -e 's/allatthesametime//'` )
-num=${#scripts[@]}
-echo "$num scripts have to be launched" >> $scriptlog 2>&1
-i=0
+num=$#
+echo "$num scripts have to be launched" #>> $scriptlog 2>&1
+i=1
 
-while [ $i -lt $num ]
+if echo $@ | grep "allatthesametime" >/dev/null 2>$errorlog
+then
+   all="yes"
+else
+   all="no"
+fi
+
+while [ $i -le $num ]
 do 
-   echo " launching ${scripts[$i]}..." >> $scriptlog 2>&1
-   pid=`/usr/local/bin/condor_submit -a path=$path -a prog=${scripts[$i]} -a date=$date -a dir=$runlogpath $path/run.condor 2>> $errorlog | grep 'submitted to cluster' | cut -dr -f2`
+   com=( )
+   prog=
+   if [ "$1" = "allatthesametime" ]
+   then
+      shift
+      i=`expr $i + 1`
+      continue
+   fi
+   com=( $1 )
+   prog=${com[0]}
+   if ! ls $path/${com[0]} >/dev/null 2>&1
+   then
+      echo "script $path/$1 does not exist." >> $scriptlog 2>&1
+      shift
+      i=`expr $i + 1`
+      continue
+   fi
+   if [ `echo $1 | wc -w` -gt 1 ]
+   then
+      unset com[0]
+      args='-a args="'${com[@]}'"'
+   fi
+   echo " launching $1..." >> $scriptlog 2>&1
+   echo "/usr/local/bin/condor_submit -a path=$path -a prog=$prog $args -a date=$date -a dir=$runlogpath $path/run.condor 2>> $errorlog | grep 'submitted to cluster' | cut -dr -f2" >> $scriptlog 2>&1
+   pid=`/usr/local/bin/condor_submit -a path=$path -a prog=$prog $args -a date=$date -a dir=$runlogpath $path/run.condor 2>> $errorlog | grep 'submitted to cluster' | cut -dr -f2`
    if [ "$pid" = "" ]
    then 
       echo `date`" WARN condor is not working " >> $errorlog 2>&1
-      printprocesslog "WARN submitting ${scripts[$i]} to condor failed"
+      printprocesslog "WARN submitting $1 to condor failed"
+      shift
+      i=`expr $i + 1`
       continue
    fi
-   if ! echo $@ | grep "allatthesametime" >/dev/null 2>$errorlog
+   if [ "$all" = "no" ]
    then
-      echo "  waiting for ${scripts[$i]} to be done..." >> $scriptlog 2>&1
+      echo "  waiting for $1 to be done..." >> $scriptlog 2>&1
       /usr/local/bin/condor_wait $runlogpath/condor-$date.log $pid >/dev/null 2>$errorlog
    fi
+   shift
    i=`expr $i + 1`
 done
