ESP Workload Automation

 View Only
Expand all | Collapse all

How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

  • 1.  How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 13, 2019 04:12 PM

    Hi everybody,

     

    I'm trying to pass a string with multiplespaces at the end as an argument in a Job using USER1/USER2 variables, but apparently the ESP is cutting off them.
    Example of string: "S        "
    What script receives: "S"

     

    The purpose is resubmit a Linux Job with a different parameter than default when its necessary.
    In this case, the operator has to select resubmit job and input the JobName in the USER1 field and the new PARM in the USER2 field.

     

    My Job:
    LINUX_JOB TESTE
       AGENT LXXX
       SCRIPTNAME /tmp/teste
       /* Alterative PARM */
       IF USER1='%ESPAPJOB' THEN ARGS '%USER2'
       /* Default PARM */
       ELSE ARGS 'N        '
       RUN WORKDAY
       USER test123
    ENDJOB



  • 2.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 07:42 AM

    Hello!

     

    Could you just set a local variable for the argument like this:

     

    IF %USER1 EQ 'N' THEN ARGS 'N  ' 

     

    Perhaps then you could have the operator simply pass an "N" and the job would then get an "N  "

     

    You could also add additional lines for other letters, such as S, or P, or whatever else you need.

     

    Of course, you can also do this at the application level.

     

    <JC>



  • 3.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 09:27 AM

    Hello JC!!

     

    I got your idea, but unfortunelly we'd have to make this table and some scripts have six spaces, others have eights, and there are lots of scripts with different options of pars .. so it would not be flexible if you know what I mean. ..

    Anyway I really say thanks for your interaction and feel free to keep trying help me.

     

    Cheers!
    Leonardo Fell



  • 4.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 08:13 AM

    Hi, 

    I think it is the shell (not ESP) that it removing the trailing blank spaces.  To verify this I tested a very simple shell script. The only line in it is below. 

    echo 'ARG1' $1 'yyyyy'

     

    I initiated the script using the command below.  There are spaces after the abc and I enclosed abc and the spaces in quotes. 

    ./test_args.sh 'abc                 ' test

     

    The trailing spaces are removed after abc in the output. 

    ARG1 abc yyyyy

     

    This makes me believe that the shell is removing the trailing spaces. I don't think it will be possible to resolve the issue in ESP.  The spaces could be added back to the argument inside the script.  

     

    Note:

    If the spaces are in the middle of the argument enclosed in quotes they are maintained. 

     

    Don



  • 5.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 09:19 AM

    Hi, Don

     

    Thanks for your response..

     

    I think you can preserve the blankspaces in the schell script using double quotes on the variable, like this:

    echo 'ARG1' "$1" 'yyyyy'

     

    At least it works here:

    ./teste 'abc                 ' test
    ARG1 abc                  yyyyy

     

    I 'd really aprecciate if you could go ahead in yours tests.

     

    Cheers

    Leonardo Fell



  • 6.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 10:28 AM

    Hi, 

    I modified my script like you suggested and the spaces were maintained when I initiated it manually. ... 

    echo 'ARG1' "$1" 'yyyyy' 

     

    I tried this out in ESP with the ARG statement below and it maintained the trailing spaces. 

    ARGS 'ABC            '

    Let me know if this doesn't work for you. 

     

    Don 



  • 7.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 11:04 AM

    Don,

     

    It works using the default ARGS in the APPL, as below:

    LINUX_JOB TESTE
       AGENT LXXX
       SCRIPTNAME /tmp/teste
       ARGS 'N        '

    ENDJOB

     

    But I want to give the option of an alternative ARG to the operator in the case of resubmission , and I tried in this way:

    LINUX_JOB TESTE
       AGENT LXXX
       SCRIPTNAME /tmp/teste
       /* Alterative PARM */
       IF USER1='%ESPAPJOB' THEN ARGS '%USER2'
       /* Default PARM */
       ELSE ARGS 'N        '

    ENDJOB

     

    In this case, if the operator doesn't input USER1/USER2, the script will use the default ARG ('N        ').

     

    But if the operator input USER1:TESTE and USER2:S        , the ESP will remove the spaces after the 'S'.

     

    I've tried input USER2 with quotes (USER2:'S        ') and the Director show me a error of "Invalid 2nd user data string".

     

    I've tried input USER2 with doublequotes (USER2:"S        ") and occurs SUBERROR on the Director, and TSO show me:

    ESPML0528E ERROR OCCURRED PROCESSING EVENT XXXLAB.LFTST IN APPL LFTST2.128
    ESPML0027E READVAL "ESPTRUSR(BXXXX)ESPTRTYPE(T)RESUB_USER() RESUB_USER(BXXXX) USER1(TESTE
    ESPML0001E UNBALANCED PARENTHESES
    ESPML0027E IF USER1='%ESPAPFULLNAME' THEN ARGS /tmp/teste '%USER2'
    ESPML0013E VARIABLE USER1 NOT DEFINED



  • 8.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 11:18 AM

    Hi, 

    Would it be possible to add the spaces in the ARGS statement like the one below?  There are spaces after the %USER2 variable and before the close quote. 

    IF USER1='%ESPAPFULLNAME' THEN ARGS /tmp/teste '%USER2         '

     

    Don



  • 9.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?

    Posted Mar 14, 2019 11:55 AM

    Don,

     

    Yes, it'd work in part. But as I was saying above to JC, unfortunelly we'd have to make a table with all options and some scripts have six spaces, others have eights, and there are lots of scripts with different options of pars, sometimes it doesn't have space at the end .. so it would not be flexible at all =(

     

    Maybe It's something that developers could change or fix...

     

    Cheers!


    Leonardo Fell



  • 10.  Re: How can I pass ARGS (USER1, USER2, etc.) with multiple withespaces at the end of the string?
    Best Answer

    Posted Mar 14, 2019 01:35 PM

    Hi, 

    The above solution would work if the same JOB/script always requires the amount of spaces.  The IF/THEN statement below would contain the correct amount of spaces for that script. This solution would not work if the number of spaces varies depending on the parameter being passed in. 

    THEN ARGS '%VAR1     '  

     

    I tried several options but I was not able to find a simple solution that used the USER variables. The best I can do is to store it in a variable and change the variable.  Then restart the job. To make the USER variable retain trailing blanks would be an enhancement request. The link is below. 

    CA Workload Automation 

     

    It does seems like there would be a better process than having required blanks at the end of an argument(and they vary in length by job).   But I understand it is a difficult thing to change.