2 Replies Latest reply on Mar 4, 2015 10:26 AM by Narahari 'n' Savitha

    Webservices, Job, output files and how to get it

    Narahari 'n' Savitha



      I wrote a nsh file and thereby a NSHScriptJob  with the name ExportPropsOfJobInFolder2File which takes a JobGroup and a JobName.  It then creates a flat file of the format.



      funcion exportPropsForJobInFolder() {


        jobGroup=$(echo "$1" | sed -e "s:^.*/USS:/USS:g" -e "s:]::g")

        #echo "$jobGroup"



        #blcli_execute JobGroup groupNameToId "$jobGroup"

        ouch "$?" $LINENO



        blcli_execute Job getDBKeyByTypeGroupAndName  "$jobGroup" "$jobName" "$jobType"

        ouch "$?" $LINENO

        blcli_storeenv jobDBKey






        mkdir -p $outputDir

        sleep 1

        touch "$outputDir"/a


        echo "$outputDir"


        blcli_execute ImportExport exportObject "$jobType" "$jobDBKey" "$outputDir"

        ouch "$?" $LINENO



        grep parameterName $dataFile | sed -e "s/^.*\[//g" -e "s/\].*//g" | sort > $outputDir/props.txt


        for i in $(cat $outputDir/props.txt)


        echo $i


        parameterIndex=$(getParameterIndexForParamName "$i" "$dataFile")

        valueInScript=$(getDefaultValueForParamName "$i" "$dataFile")

        valueInJob=$(getCurrentValueForParamName "$i" "$dataFile")

        echo "$i:$parameterIndex:$valueInScript:$valueInJob" >> $outputDir/propsWithValue.txt



      function getParameterIndexForParamName() {




        x=$(grep -w "$paramName" $dataFile -B 1 | grep "$key")

        retval=$(echo "$x" | sed -e "s/\(^.*\">\)\(.*\)\(<.*\)/\2/g")

        echo "$retval"


      function getDefaultValueForParamName() {




        x=$(grep -w "$paramName" $dataFile -A 2 | grep "$key")

        retval=$(echo "$x" | sed -e "s/\(^.*\[\)\(.*\)\(\\]].*\)/\2/g")

        echo "$retval"




      function getCurrentValueForParamName() {





        x=$(grep -w "$paramName" $dataFile -B 2 | grep "$key")

        paramIdStr=$(echo "$x" | sed -e "s/^.*=//g")

        x=$(grep "$paramIdStr" $dataFile -A 2 |  grep "field.*value.*field")

        retval=$(echo $x | sed -e "s/\(^.*\[\)\(.*\)\(\\]].*\)/\2/g")

        echo "$retval"



      exportPropsForJobInFolder "$1" "$2"

      This works well.  It puts the file(s) under /tmp/Narahari


      I am now trying to call the NSHScriptJob that I wrote above using Webservices.  I am able to call the Job and when I list the contents of /tmp/Narahari, the file exists there.


      The question is how to get the file that got created on the server ,as a part of the execution of ExportPropsOfJobInFolder2File job, back to the Webservices caller.


      Kindly help.



        • 1. Re: Webservices, Job, output files and how to get it
          Bill Robinson

          when you run this:

          blcli_execute ImportExport exportObject "$jobType" "$jobDBKey" "$outputDir"

          i think you can do this over soap w/ the ExecuteCommandWithAttachment type or something like that and it will send back the output as a base64 encoded string which you can decode and write to your local file system.

          • 2. Re: Webservices, Job, output files and how to get it
            Narahari 'n' Savitha



            I tried what you suggested and it works.  Interestingly the output for ImportExport exportObject  is a folder and when I run thru web services I receive a zip file(I figured out the hard way) and I unzip and use the file.


            So it works.  Thank you for the help.


            What I prefer to do is to do is

            a.  Run my own NSHJob from the WebServices client. (no executecommantwithattachment just execute command)

            b.  Ouptut of NSHScript job is a file is created in /tmp/Narahari/cool.txt

            c.  Inside of that job, I want to do a Utility nshCommand "cat /tmp/Narahari/cool.txt"


            This way the output of the Job I executed should now come back as text back to me, so I don't have to go thru the unzipping extracting the file etc.,