Automic Workload Automation

Expand all | Collapse all

Escaping when using &UC_JOBMD, nested quotes.

  • 1.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 11:52 AM
    Hi all,

    I'm attempted to run something from the command line with the agent UCXJWX6M.exe, that passes a username / password stored in a login object using GET_LOGIN, into a module, where these are passed as an XML string.

    This means I need to use &UC_JOBMD to run a job to decrypt the password.
    The trouble I'm having is that the command line job takes an XML string with the username/password in it as a part of the XML.  I can't figure out how to correctly escape this.  I don't want to decrypt the password separately, as I don't want it to appear in plain text in the logs.

    My current process script looks like this:

    :SET &LI# = GET_LOGIN("CLIENT_DDT.LOGIN.SYSA","*",SYSA,LOGIN_INFO)
    :SET &PW# = GET_LOGIN("CLIENT_DDT.LOGIN.SYSA","*",SYSA,PASSWORD)
    :SET &XML# = "<WizardValues><Value name='username'>&LI#</Value><Value name='password'>&PW#</Value></WizardValues>"
    &UC_JOBMD='EngineCmd.exe C:\Workflows\Module.mod "&XML#"'

    basically the XML parameter is already requiring nesting of quotes (so using " for the outside and ' for the inside) but then this has to be inside the &UC_JOBMD script too, and the usual escaping tricks ("" or \") don't work...


  • 2.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:01 PM
    Perhaps this previous discussion will help - &UC_JOBMD -- decrypted password as parameter to powershell


  • 3.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:06 PM
    Hi Mark - I did take a look at that- I think my problem is specifically that the parameter itself has nested quotes, so the end string looks something like
    &UC_JOBMD="EngineCmd.Exe C:\WORKFLOWS\Module.mod '<wizard><Values ""username"">&LI#</Values>...</wizard>"

    i.e. "somecommand.exe '<wizard... "" <-- don't know how to escape this

    The username/password stuff appears to be working okay though.


  • 4.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:06 PM
    I have encountered difficult escape sequences like this one too.  I think in one particularly difficult case I did something like the following;

    (1) Use UC_JOBMD to decrypt the password into a windows or unix variable, depending upon what type of agent I was running on.
    (2) Run the command that needs to use the password, passing it the windows/unix password variable.
    (3) Immediately clear the contents of the windows/unix password variable.


  • 5.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:10 PM
    Thanks Pete- that sounds like it should work, although I guess then the password will appear in the log file right?


  • 6.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:26 PM
    If done right, all that you see in the log file is the name of the variable you are using.


  • 7.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:29 PM
    Humm... I think I did this on a unix agent and it only logged the variable name.  I don't know if a windows implementation might expose the password or not, which of course would be unacceptable.


  • 8.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:29 PM
    I'm a V8 user and have no need nor familiarity with password decryption in a script.   However, sometime when I need to make strings that contain UC4 type delimiters I will use the following approach.  Perhaps this might work for your requirements.

    :SET &li# = "***"
    :SET &cmd = "EngineCmd.Exe C:\WORKFLOWS\Module.mod '<wizard><Values " 
    :SET &cmd = STR_CAT(&cmd,'""username"">')
    :SET &cmd = STR_CAT(&cmd,&LI#)
    :SET &cmd = STR_CAT(&cmd,"</Values>...</wizard>")
    :PRINT &cmd




  • 9.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 20, 2015 12:30 PM
    NOTE TO FORUM ADMINS: My previous post has a "user.png" attachment.  I have no idea where it came from!


  • 10.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 23, 2015 07:34 AM
    Hi again - I'm still having no joy with this -

    This does something:

    ---
    &UC_JOBMD CMD="ECHO &PW#"
    (echoes out PW in log)

    ---
    !This doesn't
    :SET &PWDC# = (&UC_JOBMD CMD="ECHO &PW#")
    echo &PWDC# 
    (shows the letter "N" (??), confirmed by piping it to a file to make sure it wasn't just a disconnect between the log view and what was actually running on the commandline.)

    ---
    !This doesn't
    SET TEST=(&UC_JOBMD CMD="ECHO &PW#")
    echo %TEST%
    (shows:
    C:\>SET TEST =(D:\uc4\Agents\Windows\bin\UCXJWX6M.EXE CMD="ECHO --10F2BB0F9780E617A0B1429E9D7F9E0B84") 
    C:\>ECHO  
    ECHO is on.

    I'm on V9 SP6 HF3

    Until I can figure out how to pass a partial bit of decrypted info to a regular command line script like this, I can't avoid the escaping issue in the intended way, which would be something like this

    ..
    :SET &PWDC# = (&UC_JOBMD CMD="SET ECHO &PW#")

    SET XML = "<Start>...<param type='Password'>&PWDC#</param></Start>"
    EngineCmd.exe module.mod %XML%

    SET XML=""

    Anyone have anything else I can try? Thanks! 


  • 11.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 23, 2015 11:52 AM
    I've confirmed that my original idea will not work, so I started playing around with it and came up with this approach, which is based upon the idea that Mark posted;

    :SET &XML1# = "^<wizardvalues>^<value name="username">&MyUser#^</Value^>^<value name="password">"
    :SET &XML2# = "^</Value^>^</WizardValues^>"
    &UC_JOBMD CMD="echo &XML1#&MyPassword# &XML2#" Yuck, forum won't display all of my escaped code, and I can't seem to get it to accept an image right now either.   I can share by email;  petwir @ saif.com</value></value></wizardvalues>


  • 12.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Feb 23, 2015 01:12 PM
    petwir I have encountered the same issue several times. I would post a comment then an attachment appears in my post even though I didn't attach anything. It's frustrating!


  • 13.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Mar 10, 2015 07:46 PM
    JGi604607 and petwir
    It appears there is a linking issue from the attachments we migrated over from the Orsyp Forum.
    Sorry about that. Not sure why it's starting to appear now, but we've raised a issue.


  • 14.  Escaping when using &UC_JOBMD, nested quotes.

    Posted Mar 29, 2015 01:05 PM
    JGi604607 and petwir
    The 'mystery' attachment issue has been resolved. Here's a link to post with more info about the cause if you're interested.