This file is indexed.

/usr/bin/globus-job-submit is in globus-gram-client-tools 10.4-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
#! /bin/sh

# 
# Copyright 1999-2006 University of Chicago
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
# http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 


#
# globus-job-run and globus-job-submit (same code base)
#

if test -n "${GLOBUS_LOCATION}" ; then
    prefix="${GLOBUS_LOCATION}"
else
    prefix="/usr"
fi

exec_prefix="${prefix}"
sbindir="${exec_prefix}/sbin"
bindir="${exec_prefix}/bin"
libdir="${prefix}/lib"
includedir="${prefix}/include/globus"
datarootdir="${prefix}/share"
datadir="${datarootdir}"
libexecdir="${datadir}/globus"
sysconfdir="/etc"
sharedstatedir="/var/lib"
localstatedir="/var"
aclocaldir="${datadir}/globus/aclocal"

. ${libexecdir}/globus-script-initializer

globus_source ${libexecdir}/globus-sh-tools.sh

PROGRAM_NAME=`echo $0 | ${GLOBUS_SH_SED-sed} -e 's|.*/||g'`
PROGRAM_VERSION='10.4'
PACKAGE='globus_gram_client_tools'
VERSION='10.4'
DIRT_TIMESTAMP='1337622354'
DIRT_BRANCH_ID='83'


case "$PROGRAM_NAME" in
*-run)
   short_usage="$PROGRAM_NAME <contact string> [-np N] <executable> [<arg>...]"
   std_file_statement="default to stdout/stdout of $PROGRAM_NAME."
   ;;
*-submit)
   short_usage="$PROGRAM_NAME [-help] <contact string> [-np N] <executable> [<arg>...]"
   std_file_statement="is retrieved later using globus-job-get-output."
   ;;
esac

long_usage ()
{
${GLOBUS_SH_CAT-cat} >&2 <<EOF

Usage: $PROGRAM_NAME
      [-help|-usage]                     print usage and exit
      [-version[s]]                      print version and exit
Usage: $PROGRAM_NAME
      [-dumprsl]                         output RSL, don't run job
      [-dryrun]                          verify RSL, don't run job
      [-verify]                          perform dryrun, then run job
      [-file             file]           read rest of arguments from file
      contact string                     only the hostname is required.
        [-np             N]              number of processing elements
        [-count          N]              same as -np
        [-host-count     nodes]          number of SMP nodes (IBM SP)
        [-m[axtime]      minutes]        time to allocate for the job
        [-p[roject]      projectID]      scheduling/accounting project ID
        [-q[ueue]        queueID]        scheduling/accounting queue ID
        [-d[ir]          directory]      working directory
        [-env            name=value]...  environment binding
        [-stdin  [-l|-s] file]           input
        [-stdout [-l|-s] file]           output
        [-stderr [-l|-s] file]           error output
        [-x rsl-clause]                  RSL extension capability
        [-l|-s] executable [args...]     executable and clause arguments

   Job stdin defaults to /dev/null.
   Job stdout/stderr $std_file_statement

   The file modifiers -l and -s specify different filespaces:
      -l[ocal]  file is relative to working directory of job      (DEFAULT)
      -s[tage]  file relative to job request is staged to job host

   The working directory of the submitted job defaults to \$HOME.

   Valid forms of the contact string are:
       hostname
       hostname:port
       hostname:port/service
       hostname/service
       hostname:/service
       hostname::subject
       hostname:port:subject
       hostname/service:subject
       hostname:/service:subject
       hostname:port/service:subject

   If more than one setting is defined (such as two -stdin definitions),
   the setting defined last on the command line will be used.

EOF
}

globus_source ${libexecdir}/globus-args-parser-header "$@"

rslfile=${TMPDIR:-/tmp}/globus_job_run.`${GLOBUS_SH_WHOAMI-whoami}`.rsl.$$
tmpfile=${TMPDIR:-/tmp}/globus_job_run.`${GLOBUS_SH_WHOAMI-whoami}`.tmp.$$


remove_files ()
{
    ${GLOBUS_SH_RM-rm} -f ${rslfile} ${tmpfile}
}


error_exit ()
{
    globus_args_short_usage
    exit $1
}


stringify ()
{
    #
    # NOTE: if the argument contains the pattern $(...), it is most likely
    # an RSL substitution: if so, suppress quoting.
    #
    arg="`${GLOBUS_SH_CAT-cat} -`"

    if [ "X`printf "%s" "${arg}" | ${GLOBUS_SH_SED-sed} -n '/\$(.*)/p'`" = "X" ]; then
        printf "%s" "${arg}" | ${GLOBUS_SH_SED-sed} -e 's/"/""/g' -e 's/^.*$/"&"/g'
    else
        printf "%s" "${arg}"
    fi
}


parse_integer ()
{
    if ${GLOBUS_SH_EXPR-expr} "$2" + 1 - 1 \> 0 > /dev/null 2>&1 ; then
	result="$2"
    else
	globus_args_option_error "$1" "\"$2\" is not an integer"
    fi
}


get_real_pwd ()
{
    file="$1"
    #
    # Try to figure out PWD (the real PWD, not an automounted PWD or an
    # incorrect env.var...)
    # This code is at large based on code from the MPICH mpirun command,
    # where they try to solve the same problem.
    #
    PWDtest="`${GLOBUS_SH_PWD-pwd} | ${GLOBUS_SH_SED-sed} 's@/tmp_mnt/@/@g'`"
    if [ ! -d "$PWDtest" ] ; then
        PWDtest="`${GLOBUS_SH_PWD-pwd}`"
    fi
    if [ -n "$PWD" ] ; then
        PWDtest2=`echo $PWD | ${GLOBUS_SH_SED-sed} 's@/tmp_mnt/@/@g'`
	if [ ! -r "${PWDtest2}/file" ]; then
            PWD=$PWDtest2
	else
            PWD=$PWDtest
        fi
    else
        PWD=$PWDtest
    fi
    echo "$PWD/$file"
}


normalize_filename()
{
   case "$1" in
     /* )
        file="$1"
        ;;
     * )
        file=`get_real_pwd "$1"`
        ;;
   esac

   # collapse all sequences of '/'s to a single '/'
   #
   file=`echo $file | ${GLOBUS_SH_SED-sed} -e 's://*:/:g'`

   # collapse all instances of "/./" to a single '/'
   # note we must loop for all series forms "/././" because
   # the patterns overlap and only half match in each iteration
   #
   while echo $file | ${GLOBUS_SH_GREP-grep} '/\./' > /dev/null 2>&1
   do
      # this goes faster when we inline a couple iterations
      # into one sed command
      file=`echo $file | ${GLOBUS_SH_SED-sed} -e 's:/\./:/:g' \
                             -e 's:/\./:/:g'`
   done

   # reduce all '/../' expressions
   #    root is its own parent
   #    foo/bar/../ is foo iff bar!=..
   while echo $file | ${GLOBUS_SH_FGREP-fgrep} '/\.\./' > /dev/null 2>&1
   do
      file=`echo $file | ${GLOBUS_SH_SED-sed} -e 's:^/\.\./:/:g' \
                             -e 's:/[^./][^/]*/\.\./:/:g' \
                             -e 's:/\.[^./][^/]*/\.\./:/:g' \
                             -e 's:/\.\.[^/][^/]*/\.\./:/:g'`
   done

   # remove trailing '/.' or '/'
   #
   file=`echo $file | ${GLOBUS_SH_SED-sed} -e 's:/$::g' \
                          -e 's:\(/\.\)*$::g'`

   echo $file
}


read_argument_file()
{
    cat $1 |
    (
	arglist=
	while read inp ; do
	    arglist="${arglist} ${inp}"
	done
	echo "${arglist}"
    )
}

emit_subjob_rsl ()
{
    #
    # extra RSL should take precedence: therefore, it needs to come first
    #
    if [ ${job_is_multi} = "true" ]; then
	echo "( &${subjob_extra_rsl}(resourceManagerContact=\"${job_contact}\")"
	echo "   (subjobStartType=strict-barrier)"
	echo "   (label=\"subjob ${job_hostclause_count}\")"
	echo "   (executable=$executable)"
    else
        if [ -n "${subjob_extra_rsl}" ] ; then
           echo " &${subjob_extra_rsl}"
           echo "   (executable=$executable)"
        else
           echo "  &(executable=$executable)"
        fi
    fi
    if [ ! "X$project" = "X" ] ; then
	echo "   (project=$project)"
    fi
    if [ ! "X$queue" = "X" ] ; then
	echo "   (queue=$queue)"
    fi
    if [ ! "X$maxtime" = "X" ] ; then
	echo "   (maxtime=$maxtime)"
    fi
    if [ ! "X$directory" = "X" ] ; then
	echo "   (directory=$directory)"
    fi
    if [ ! "X$job_environment" = "X" ] || \
       [ ! "X$subjob_environment" = "X" ] ; then
	echo "   (environment=${job_environment}${subjob_environment})"
    fi
    if [ ! "X$count" = "X" ] ; then
	echo "   (count=$count)"
    fi
    if [ ! "X$host_count" = "X" ] ; then
	echo "   (host_count=$host_count)"
    fi
    if [ ! "X$subjob_args" = "X" ] ; then
	echo "   (arguments=$subjob_args)"
    elif [ ! "X$arguments" = "X" ] ; then
	echo "   (arguments=$arguments)"
    fi
    if [ ! "X$subjob_stdin" = "X" ] ; then
	echo "   (stdin=$subjob_stdin)"
    elif [ ! "X$job_stdin" = "X" ] ; then
	echo "   (stdin=$job_stdin)"
    fi
    if [ ! "X$subjob_stdout" = "X" ] ; then
	echo "   (stdout=$subjob_stdout)"
    elif [ ! "X$job_stdout" = "X" ] ; then
	echo "   (stdout=$job_stdout)"
    fi
    if [ ! "X$subjob_stderr" = "X" ] ; then
	echo "   (stderr=$subjob_stderr)"
    elif [ ! "X$job_stderr" = "X" ] ; then
	echo "   (stderr=$job_stderr)"
    fi
    if [ ${job_is_multi} = "true" ]; then
	echo ")"
    fi
}


parse_fileopt ()
{
    #
    # given input: <option> [-l[ocal]|-s[tage]] filename ...
    #
    # where <option> is one of -std{in,out,err}, -file, executable
    # if -l or -s is not defined, -l is assumed.
    #
    # The following settings are triggered:
    #
    # PROGRAM_NAME    option             flag   action
    # -----------------------------------------------------------
    # run         -stdin,executable  -s     enable GASS read
    # run         -stdout,-stderr    -s     enable GASS write
    # submit      -stdout,-stderr    all    disable GASS caching
    #

    opt="$1"
    if [ $# -eq 1 ]; then
	globus_args_option_error "${opt}" "needs a filename argument"
    fi

    stagevar=dummy
    dont_stringify=0
    case "${PROGRAM_NAME}:${opt}" in
	*-run:-stdin | *-run:executable)
	    stagevar=job_needs_gass_read
	    ;;
	*-run:-stdout | *-run:-stderr)
	    stagevar=job_needs_gass_write
	    ;;
	*-submit:-stdout)
	    job_cache_stdout=false
	    ;;
	*-submit:-stderr)
	    job_cache_stderr=false
	    ;;
        *:-file)
            dont_stringify=1
            ;;
    esac

    shift

    case "$1" in
    -s | -stage)
	if [ $# -eq 1 ]; then
	    globus_args_option_error "${opt} $1" "needs a filename argument"
	fi
	file=`normalize_filename "$2" | stringify`
	result=`echo '$(GLOBUSRUN_GASS_URL)' '#' "${file}"`
	eval ${stagevar}=true
	stage_executable=true
	return 3
	;;
    -l | -local)
	if [ $# -eq 1 ]; then
	    globus_args_option_error "${opt} $1" "needs a filename argument"
	    return 0
	fi
	result=`echo "$2" | stringify`
	return 3
	;;
    -*)
	globus_args_option_error "${opt}" "needs a filename argument"
	return 0
	;;
    *)
        if test "$dont_stringify" = 1; then
            result=$1
        else
            result=`echo "$1" | stringify`
        fi
	return 2
	;;
    esac
}


parse_environment ()
{
    shift 1
    if [ ! "$#" = "0" ] ; then
	case "$1" in
	?*=*)
	    name=`echo "$1" | ${GLOBUS_SH_SED-sed} -e 's/^\([^=]*\)=\(.*\)/\1/g'`
	    value=`echo "$1" | ${GLOBUS_SH_SED-sed} -e 's/^\([^=]*\)=\(.*\)/\2/g'`
	    echo "("`echo "$name" | stringify` `echo "$value" | stringify`")"
	    return 2
	    ;;
	*)
	    globus_args_option_error "-env" "invalid environment string \"$1\""
	    ;;
	esac
    else
	globus_args_option_error "-env" "missing environment string!"
    fi
}

parse_user_args ()
{
    shift_count=0
    temp_arguments=""
    while ${GLOBUS_SH_EXPR-expr} "$#" \> 0 > /dev/null 2> /dev/null ; do
        arg=`printf "%s" "$1" | stringify`
        temp_arguments="${temp_arguments} ${arg}"
        shift
        shift_count=`${GLOBUS_SH_EXPR-expr} "$shift_count" + 1 2> /dev/null`
    done

    echo "$temp_arguments"
    return $shift_count
}

parse_hostclause ()
{
    count=""
    host_count=""
    maxtime=""
    executable=""
    directory=""
    project=""
    queue=""
    subjob_environment=""
    subjob_stdin=""
    subjob_stdout=""
    subjob_stderr=""
    subjob_args=""
    clause_done="false"

    if [ $# -eq 0 ]; then
	echo "ERROR: empty host-clause" >& 2
	return 0
    fi

    # "$1" should be the contact string
    #
    case "$1" in
	-*)
	    globus_args_option_error "$1" \
			       "contact string must be first in host-clause"
	    ;;
	*)
	    job_contact="$1"
	    ;;
    esac

    shift 1
    shift_count=1

    while [ $# -gt 0 -a "${clause_done}" = "false" ]; do
	case "$1" in
	-np | -count | \
	-host-count | \
	-m  | -maxtime | \
	-p  | -project | \
	-q  | -queue | \
	-d  | -dir | \
	-x  | -extrarsl)
	    if [ $# -lt 2 ]; then
		globus_args_option_error "$1" "missing argument"
	    fi
	    case "$1" in
		-np | -count)
		    parse_integer "$@"
		    count=${result}
		    ;;
		-host-count)
		    parse_integer "$@"
		    host_count=${result}
		    ;;
		-m | -maxtime)
		    parse_integer "$@"
		    maxtime=${result}
		    if [ ${maxtime} -gt ${job_maxtime} ]; then
			job_maxtime=${maxtime}
		    fi
		    ;;
		-p | -project)
		    project=`echo "$2" | stringify`
		    ;;
		-q | -queue)
		    queue=`echo "$2" | stringify`
		    ;;
		-d | -dir)
		    directory=`echo "$2" | stringify`
		    ;;
		-x | -extrarsl)
		    case "$2" in
		    \&*)
			subjob_extra_rsl=`echo "$2" | \
				    ${GLOBUS_SH_SED-sed} 's/^&//'`
			;;
		    *)
			subjob_extra_rsl="$2"
			;;
		    esac
		    ${bindir}/globusrun -p "&${subjob_extra_rsl}" \
			1>/dev/null 2>/dev/null
		    if [ $? -ne 0 ]; then
			globus_args_option_error "$1" "cannot parse RSL stub"
		    fi
		    ;;
	    esac
	    shift 2
	    shift_count=`${GLOBUS_SH_EXPR-expr} $shift_count + 2`
	    ;;
	-stdin | -stdout | -stderr)
	    parse_fileopt "$@"
	    stdio_shift=$?
	    if [ ${stdio_shift} -eq 0 ]; then
		return 0
	    fi
	    case "$1" in
		-stdin)
		    subjob_stdin=${result}
		    ;;
		-stdout)
		    subjob_stdout=${result}
		    ;;
		-stderr)
		    subjob_stderr=${result}
		    ;;
	    esac
	    shift $stdio_shift
	    shift_count=`${GLOBUS_SH_EXPR-expr} $shift_count + $stdio_shift`
	    ;;
	-env)
	    subjob_environment=${subjob_environment}\ `parse_environment "$@"`
	    env_shift=$?
	    if [ ${env_shift} -eq 0 ] ; then
		return 0
	    else
		shift $env_shift
		shift_count=`${GLOBUS_SH_EXPR-expr} $shift_count + $env_shift`
	    fi
	    ;;
	*)
	    case "$1" in
		-l* | -s*)
		    dummy=xyz
		    ;;
		-*)
		    globus_args_unrecognized_option "$1"
		    ;;
	    esac
	    #
	    # this should be  [-l|-s] executable [args...]
	    # where [args...] is terminated by EOL
	    #
	    # fileopt() needs a "executable" option first though.
	    #
	    parse_fileopt "executable" "$@"
	    exec_shift=$?
	    if [ ${exec_shift} -eq 0 ]; then
		return 0
	    fi
	    executable=${result}
	    #
	    # added a phantom "executable" argument above: adjust for that
	    exec_shift=`${GLOBUS_SH_EXPR-expr} $exec_shift - 1`
	    shift $exec_shift
	    shift_count=`${GLOBUS_SH_EXPR-expr} $shift_count + $exec_shift`

	    # and now the arguments...
	    #
	    while [ ! "$#" = "0" ]; do
                if [ "$1" = "--" ]; then
                    shift_count=`${GLOBUS_SH_EXPR-expr} $shift_count + 1`
                    if [ $# -ge 2 -a "$2" = "--" ]; then
                        shift
                    else
                        shift
                        continue
                    fi
		fi
		subjob_args="$subjob_args `printf "%s" "$1" | stringify`"
		shift_count=`${GLOBUS_SH_EXPR-expr} $shift_count + 1`
		shift
	    done
	    clause_done=true
	    ;;
	esac
    done

    if [ -z "${executable}" ]; then
	echo "ERROR: no executable in host-clause" >&2
	return 0
    fi

    emit_subjob_rsl
    return $shift_count
}


parse_global_opts ()
{
    while [ ! "$#" = "0" ] ; do
	case "$1" in
	-dump | -dumprsl )
	    shift
	    job_print_rsl=true
	    job_submit=false
	    ;;
	-dryrun)
	    shift
	    job_verify=true
	    job_submit=false
	    ;;
	-verify)
	    shift
	    job_verify=true
	    job_submit=true
	    ;;
	-- )
	    shift 1
	    arguments=`parse_user_args "$@"`
	    shift $?
	    ;;
	*)
	    single_flag=`${GLOBUS_SH_EXPR-expr} ${single_flag} + 1`
	    if [ ${job_is_multi} = true -o ${single_flag} -gt 1 ]; then
		globus_args_option_error "$1" \
				      "Cannot mix single and multi-req syntax"
	    fi
	    parse_hostclause "$@"
	    shift_count=$?
	    if [ ${shift_count} -eq 0 ]; then
		return 1
	    fi
	    shift $shift_count
	    job_hostclause_count=`${GLOBUS_SH_EXPR-expr} $job_hostclause_count + 1`
	    ;;
	esac
    done

    if [ "$job_hostclause_count" = 0 ] ; then
	echo "ERROR: Every job requires at least one host-clause!" >&2
	return 1
    fi

}


parse_top ()
{
    # Default global settings
    #
    mds_search_options=""
    job_stdin=""
    job_stdout=""
    job_stderr=""
    job_environment=""
    job_contact=""
    job_maxtime=120             # two hours
    job_is_multi=false

    job_print_rsl=false
    job_verify=false
    job_submit=true

    job_needs_gass_read=false
    job_needs_gass_write=false
    job_needs_gass_output=true

    stage_executable=false
    job_cache_stdout=false
    job_cache_stderr=false
    job_gass_cache_tag="x-gass-cache://\$(GLOBUS_GRAM_JOB_CONTACT)"

    # there are some differences in default settings for job-run and
    # job-submit....
    #
    case "${PROGRAM_NAME}" in
	*-submit)
	    job_needs_gass_output=false
	    job_cache_stdout=true
	    job_cache_stderr=true
	    job_stdout="${job_gass_cache_tag}stdout anExtraTag"
	    job_stderr="${job_gass_cache_tag}stderr anExtraTag"
	    ;;
    esac

    single_flag=0
    job_hostclause_count=0

    parse_global_opts "$@"
}


#################################################
## validation pass gathers job argument list

trap remove_files 0 1 2 9 13 15

if [ $# -eq 0 ]; then
    globus_args_short_usage
    exit 1
fi

for file in ${rslfile} ${tmpfile} ; do
    ${GLOBUS_SH_RM-rm} -f ${file}
    ${GLOBUS_SH_TOUCH-touch} ${file}
    if [ $? -ne 0 ] ; then
	echo "ERROR: Could not create temporary file \"${file}\"!" >&2
	error_exit 1
    fi
done


if parse_top "$@" > ${rslfile}
then

    if [ "${job_print_rsl}" = "true" ]; then
	${GLOBUS_SH_CAT-cat} ${rslfile}
    fi

    gassflag=""
    batchflag="-fast-batch"
    if [ ${job_needs_gass_output} = true ]; then
	gassflag="-o"
	batchflag="-b"
    fi
    if [ ${job_needs_gass_read}   = true ] || \
       [ ${stage_executable}      = true ] ; then
	gassflag="-s"
	batchflag="-b"
    fi
    if [ ${job_needs_gass_write}  = true ]; then
	gassflag="-w"
	batchflag="-b"
    fi

    case "${PROGRAM_NAME}:${job_is_multi}" in
	*submit:true)
	    echo "this statement should never have been executed" >&2
	    error_exit 1
	    ;;
	*submit:false)
	    globusrun_args="${gassflag} ${batchflag} -r \"${job_contact}\" -f ${rslfile}"
	    ;;
	*run:true)
	    globusrun_args="${gassflag} -f ${rslfile}"
	    ;;
	*run:false)
	    globusrun_args="${gassflag} -r \"${job_contact}\" -f ${rslfile}"
	    ;;
    esac

    # Check if proxy exists and is valid long enough.
    #
    if [ ${job_verify} = true -o ${job_submit} = true ]; then
	${bindir}/grid-proxy-info -exists
	if [ $? -ne 0 ]; then
	    echo "ERROR: proxy does not exist" >&2
	    error_exit 1
	fi
	hours=`${GLOBUS_SH_EXPR-expr} ${job_maxtime} / 60 + 1`
	${bindir}/grid-proxy-info -exists -valid "${hours}:0"
	if [ $? -ne 0 ]; then
	    echo "ERROR: proxy is not valid long enough " \
		 "(${hours} hours)" >&2
	    error_exit 1
	fi
    fi

    # Dryrun to see if things will be OK.
    #
    if [ "${job_verify}" = "true" ]; then
	eval ${bindir}/globusrun "-d ${globusrun_args}"  1>${tmpfile} 2>&1
	if [ $? -ne 0 ]; then
	    echo "ERROR: verify failed:" >&2
	    ${GLOBUS_SH_CAT-cat} ${tmpfile} >&2
	    error_exit 1
	else
	    echo "Dryrun successful" >&2
	fi
	if [ ${job_cache_stdout} = true -o ${job_cache_stderr} = true ]; then
	    jobid=`${GLOBUS_SH_GREP-grep} x-nexus ${tmpfile}`
	    basecmd="\$bindir/globus-gass-cache -cleanup-url x-gass-cache://"
	    command=
	    if [ ${job_cache_stdout} = true ]; then
		command="${basecmd}${jobid}stdout"
	    fi
	    if [ ${job_cache_stderr} = true ]; then
		command="${command} ; ${basecmd}${jobid}stderr"
	    fi
	    if [ -n "${command}" ]; then
		echo ${bindir}/globusrun -q -b -r "${job_contact}" \
                   "&(executable=\${bindir}//globus-sh-exec) \
		     (arguments=-e \"${command}\")"
	    fi
	fi
    fi

    # Just do it (tm).
    #
    if [ "${job_submit}" = "true" ]; then
	eval ${bindir}/globusrun "-q ${globusrun_args}"
	return_status=$?
	exit $return_status
    fi

    exit 0
else
    error_exit 1
fi