[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] condor_submit with -append arguments



This is possible, but a bit confusing.  Here's a version that I think
should work for you.  I changed only the last line.  I'll explain below.

#!/bin/sh
if [ $# -lt 1 ]
    then
    echo "Usage: ./submit_job.sh <radius> <length>"
    echo "E.g, ./submit_job.sh 60 80"
    exit
fi
radius=$1
length=$2
condor_submit -append "args = \$(Process) ${radius} ${length}"  an.job

Now to explain: I should have been more clear before that Condor's
submit file syntax is different to shell syntax on the point of variable
expansion.  Condor -does- use $(variable) notation (for historical
reasons).  But shell, /bin/sh, uses ${variable}.

What you need is to ensure that where a shell script expands a variable,
you're using ${}, and where Condor is expanding a variable, you use $().
So I changed ${Process} to $(Process).  If you tried this, you probably
got a message like "Process: command not found".

Here's the catch: since $() is also meaningful to shell, you must ensure
that shell does not evaluate that expression when sending the text to
Condor. That's what the \ symbol does: it tells shell to produce a
$ literally, instead of interpreting it.  When you write $(Process)
in the shell script, it tries to run a program named Process and
insert the output. When you write \$(Process) it just inserts the text
"$(Process)", allowing Condor to handle that when it gets appended to
your submit data.


* On 21 Nov 2014, Adriana Bungau wrote: 
> Hello,
> 
> Sorry, I just realized I should have used the mailing list. Thank you very much for your help. I am really glad the arguments can be passed this way. But I do have one more question please. In the previous question I simplified the problem a bit, in order to illustrate what I wanted. What I really need is to pass the two arguments (radius, length) while still using the $(Process) as argument variable. So my script now looks like:
> 
> $ cat > submit_job.sh
> #!/bin/sh
> if [ $# -lt 1 ]
>     then
>     echo "Usage: ./submit_job.sh <radius> <length>"
>     echo "E.g, ./submit_job.sh 60 80"
>     exit
> fi
> radius=$1
> length=$2
> condor_submit -append "args = ${Process} ${radius} ${length}"  an.job
> 
> 
> to be executed as something like ./submit_job.sh 32 40. But now $(Process) or ${Process} is not used. Would it be possible to use the two input parameters together with the corresponding job process number?
> 
> Thank you,
> 
> Adriana
> 
> ________________________________________
> From: David Champion [dgc@xxxxxxxxxxxx]
> Sent: Friday, November 21, 2014 6:06 AM
> To: HTCondor-Users Mail List
> Cc: Adriana Bungau
> Subject: Re: condor_submit with -append arguments
> 
> Hi Adriana -
> 
> * On 20 Nov 2014, Adriana Bungau wrote:
> > Second file I want to execute using some input parameters:
> >
> > $ cat > submit_job.sh
> > if [ $# -lt 1 ]
> >     then
> >     echo "Usage: ./submit_job.sh <radius> <length>"
> >     echo "E.g, ./submit_job.sh 60 80"
> >     exit
> > fi
> > radius=$1
> > length=$2
> > condor_submit -append 'args = $(radius) $(length)'  an.job
> 
> Your arguments are getting into the script OK, but they're not being
> delivered to condor_submit.  There are two reasons for that:
> 
> * You need {curly braces}, not (parentheses), for variable expansions.
> $(x) substitutes the output from the command "x" instead.
> 
> * You need "double quotes", not 'single quotes', to permit variable
> expansion. Single quotes will copy the quoted material literally,
> without allowing variables to expand.  (Sometimes that's what you want.)
> 
> I would also advise always beginning a shell script with #!/bin/sh or
> #!/bin/bash.  This is not always necessary, but it is always safe and
> it protects you from some strange edge cases.
> 
> So a modified script might be:
> 
> $ cat > submit_job.sh
> #!/bin/sh
> if [ $# -lt 1 ]
>     then
>     echo "Usage: ./submit_job.sh <radius> <length>"
>     echo "E.g, ./submit_job.sh 60 80"
>     exit
> fi
> radius=$1
> length=$2
> condor_submit -append "args = ${radius} ${length}"  an.job
> 
> --
>        David Champion â dgc@xxxxxxxxxxxx â University of Chicago
> Enrico Fermi Institute â Computation Institute â USATLAS Midwest Tier 2
>                       OSG Connect â CI Connect
> University of Huddersfield inspiring tomorrow's professionals.
> [http://marketing.hud.ac.uk/_HOSTED/EmailSig2014/EmailSigFooter.jpg]
> 
> This transmission is confidential and may be legally privileged. If you receive it in error, please notify us immediately by e-mail and remove it from your system. If the content of this e-mail does not relate to the business of the University of Huddersfield, then we do not endorse it and will accept no liability.
> 
> _______________________________________________
> HTCondor-users mailing list
> To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
> subject: Unsubscribe
> You can also unsubscribe by visiting
> https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users
> 
> The archives can be found at:
> https://lists.cs.wisc.edu/archive/htcondor-users/

-- 
       David Champion â dgc@xxxxxxxxxxxx â University of Chicago
Enrico Fermi Institute â Computation Institute â USATLAS Midwest Tier 2
                      OSG Connect â CI Connect