Author Topic: arsdoc functionality  (Read 5428 times)

j4jims

  • Guest
arsdoc functionality
« on: September 30, 2015, 12:45:13 AM »
Hi all,

I had written a script to generate the arsdoc query to be executed for a certain search criteria.

The script generates the arsdoc command exactly in the format of how it should be.

But I get this error.

ARS6054E The header format is invalid.  Syntax is as follows (Parentheses are required):
        (ag_name1)(ag_name2)(ag_name3)



But when I echo the value that is generated by the script it has exactly the values of how it should be and If I execute the query seperately its giving me the result.

I am puzzled on this. Any help would be greatly appreciated.

            /opt/IBM/ondemand/V9.0/bin/arsdoc query -h $HOSTNAME -u $USERNAME -p $PASSWORD -f \"$lineb\" -N "\"\($primarykey\)\($FIELD\)"\" -i \"where $primarykey='$linea'\" -o "\"$OUTDIR/$linea$folname.txt\""

where lineb is the foldername to be searched.
primarykey is the search criteria
linea is the indexvalue

echoing the above gives me the value as below.

/opt/IBM/ondemand/V9.0/bin/arsdoc query -h cmodsyst -u ERKAPIBAT -p xxxxxxx -f "Annuity Statements" -N "(PolNum)(CMOD_DOC_ID)" -i "where  PolNum='99135265'" -o "/opt/docucorp/input/erktest/99135265AnnuityS.txt"

But is thowing this error when executed through script

ARS6054E The header format is invalid.  Syntax is as follows (Parentheses are required):
        (ag_name1)(ag_name2)(ag_name3)



-Jim




« Last Edit: September 30, 2015, 01:23:59 AM by Justin Derrick »

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2228
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: arsdoc functionality
« Reply #1 on: September 30, 2015, 01:43:09 AM »
What's likely happening is that you are losing the quote characters when it's being processed in the script.

Check the quoting rules for your script of choice.  You may need to do something like build the list of parameters inside a pair of single quotes (which limits interpolation/interpretation of special characters), or add an extra backslash immediately before the already-escaped quote character, like this -> \\\"

Good luck!

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

j4jims

  • Guest
Re: arsdoc functionality
« Reply #2 on: September 30, 2015, 04:26:26 AM »
Thanks for your assistane JD.

Hurray, found where it went wrong !!!

The error is due that the shell consider the dynamic value as a single parameter and hence arsdoc command was not able to interpret it though it was generated exactly in the script.

Resolved by using eval command in script  ;D ;D ;D

-Jim.



Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2228
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: arsdoc functionality
« Reply #3 on: September 30, 2015, 06:49:40 AM »
Resolved by using eval command in script  ;D ;D ;D

Would you mind posting your (working) sample code so others can benefit from your wisdom in the future?  :D  Thanks!

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

j4jims

  • Guest
Re: arsdoc functionality
« Reply #4 on: September 30, 2015, 07:14:54 AM »
Never mind  :) :) :) :) :)

But have masked the fields. Its more of a generic format which one can customize  ;D

Here you go...

ABSPATH='/opt/docucorp/ondemand/V9.0/bin'
FIELD='XXXXXXX'

########################
# START OF MAIN SCRIPT #
########################

while read linea
        do
            while read lineb
                  do
                      if [[ $lineb == 'XXXXXXXXX' ]]
                         then
                         {
                            primarykey=YYYYYYYYYY
                            folname=AAAAAAAAAAA
                         }
                      elif [[ $lineb == 'ZZZZZZZZ' ]]
                           then
                         {
                            primarykey=CCCCCCCCCCC
                            folname=$lineb
                         }
                      else
                         {
                             primarykey=DDDDDDDDDD
                             folname=$lineb
                         }
                      fi
             r=$(echo "query -h $HOSTNAME -u $USERNAME -p $PASSWORD -f \"$lineb\" -N \"($primarykey)($FIELD)\" -i \"where $primarykey='$linea'\" -o \"$OUTDIR/$linea$folname.txt\"")
             
             eval "$ABSPATH/arsdoc $r"

                    if [[ $? -eq 0 ]]
                     then
                         echo "$linea Successfully retrieved 'XXXXXXX' for folder $lineb" >> $LOGDIR/$SUCCESSLOG
                  else
                         echo "$linea Failed to retrieve 'XXXXXXX' for folder $lineb" >> $LOGDIR/$FAILURELOG
                  fi
            done < FOLDERLIST_FILE
done < INDEXKEY_FILE


# END OF MAIN SCRIPT #


-Jim.

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
    • View Profile
Re: arsdoc functionality
« Reply #5 on: September 30, 2015, 08:11:19 AM »
Hello j4jims,

I don't understand why you need to do an "eval" ?? can't you just that?

Code: [Select]
           ... 
             $ABSPATH/arsdoc query -h $HOSTNAME -u $USERNAME -p $PASSWORD -f "${lineb}" -N "(${primarykey})(${FIELD})" -i "where ${primarykey}='${linea}'" -o "${OUTDIR}/${linea}${folname}.txt"
             ...

instead of

Code: [Select]
             ...
             r=$(echo "query -h $HOSTNAME -u $USERNAME -p $PASSWORD -f \"$lineb\" -N \"($primarykey)($FIELD)\" -i \"where $primarykey='$linea'\" -o \"$OUTDIR/$linea$folname.txt\"")
             eval "$ABSPATH/arsdoc $r"
             ...

????

eval is a powerful command and if you intend to use it you should be very careful to head off the possible security risks that come with it.
(http://mywiki.wooledge.org/BashFAQ/048)

and in your case, I don't see any reasons to use "eval" at all... or am I missing something?
« Last Edit: September 30, 2015, 08:14:36 AM by Alessandro Perucchi »
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

j4jims

  • Guest
Re: arsdoc functionality
« Reply #6 on: September 30, 2015, 11:22:26 PM »
I do agree  :)

Yep .. You miss something here.

First I executed the arsdoc query without using eval command. But when I execute the query string that is generated dynamically in the script the shell interprets the whole value as string and ended up with this error.

$ABSPATH/arsdoc query -h $HOSTNAME -u $USERNAME -p $PASSWORD -f "${lineb}" -N "(${primarykey})(${FIELD})" -i "where ${primarykey}='${linea}'" -o "${OUTDIR}/${linea}${folname}.

ARS6054E The header format is invalid.  Syntax is as follows (Parentheses are required):
        (ag_name1)(ag_name2)(ag_name3)


But actually there is no error in the command that was generated as it produces result in the  command window for CMOD

Finally found that the shell interprets it as a string rather individual parameters for arsdoc command.

Hence used eval command wherein the shell is able to interpret the parameters in the right way for arsdoc command and it produced the result.

r=$(echo "query -h $HOSTNAME -u $USERNAME -p $PASSWORD -f \"$lineb\" -N \"($primarykey)($FIELD)\" -i \"where $primarykey='$linea'\" -o \"$OUTDIR/$linea$folname.txt\"")
             eval "$ABSPATH/arsdoc $r"



Hope that justifies why I used eval command  :D

- Jim.



Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
    • View Profile
Re: arsdoc functionality
« Reply #7 on: October 01, 2015, 04:16:09 AM »
Strange what shell do you use? Using KSH and BASH the behaviour is exactly the same:

Code: [Select]
$ echo "(${PWD})"
(/home/demo)

As long as you put the double quote, you have never problems with parenthesis... that's why I'm quite confused... and I do it since years, and never needed to use the eval trick.
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

j4jims

  • Guest
Re: arsdoc functionality
« Reply #8 on: October 01, 2015, 04:40:52 AM »
Even I use K-shell.

parenthesis are echoed using echo statement as you said in example in the query. But arsdoc when executing it prompted this error code.

ARS6054E The header format is invalid.  Syntax is as follows (Parentheses are required):
        (ag_name1)(ag_name2)(ag_name3)

-Jim.