Automic Workload Automation

 View Only

  • 1.  Script to read the file

    Posted Nov 21, 2024 07:13 AM

    Hi Team,

    I need a script for the below cases,

    1. Open the file

    2.Read the 11th column

    3.In regard to filenames, i need to tranfer the file to different target paths.

    Quick help would be appreciated.

    Thanks and regards,

    Shravya



  • 2.  RE: Script to read the file

    Posted Nov 21, 2024 10:09 AM
    Edited by Daryl Brown Nov 21, 2024 10:16 AM

    You're missing some of pertinent details here...

    • What OS (agent) are we working with here?
    • How are the columns delimited in this file?  (e.g., commas? semicolons? pipes? tabs?)  Or did you mean we're supposed to read the 11th character of each line?

    I don't understand what the ask is with your third point (transferring files to different target paths).  What is the challenge here?




  • 3.  RE: Script to read the file

    Posted Nov 22, 2024 04:20 AM

    Hi Daryl,

    We have the requirement to transfer the file from source to target and then read the 11th column of the file (every line), as per the Locations mentioned we need to send the file to the similar locations(targets).

    The file data is separated by pipeline.

    To insert the data we are using SQL agent in automic.

    Let me know if anything is needed.




  • 4.  RE: Script to read the file

    Posted Nov 22, 2024 09:22 AM

    I'm still not completely following here.

    Is column 11 the field that lists the destination for the file?

    If the file has, say, 10 rows, does that mean you're trying to copy this one file to 10 different locations?

    Are these different locations just different paths accessible from the OS agent (not the SQL agent), or are we talking about doing File Transfers (agent-to-agent) here?

    The PREP_PROCESS_FILE function should help you with parsing the file and reading the 11th field, but I'm fuzzy on what's supposed to happen from that point.  You could either use your loop to activate a separate job/workflow to do the file copy (using ACTIVATE_UC_OBJECT) to each individual destination, or perhaps just invoke a copy/cp command (again, not sure what OS we're dealing with here) to copy the file.




  • 5.  RE: Script to read the file

    Posted Nov 28, 2024 01:20 AM

    Hi Daryl,

    I need to open the file, check for the 11th column where the location will be present. In regards to that i need to send the file for that location.

    I have created a script to check for the 11th column, please let me know how to send the file for the particular location.




  • 6.  RE: Script to read the file

    Posted Dec 02, 2024 09:53 AM

    I'm still not clear if (1) these destination paths are accessible from the same server as the file, (2) what operating system you're dealing with, and (3) whether this file with the 11th column contains multiple destinations or just one.

    For starters, I'll assume you've established UC4 script variables for your source file (&FILE#) and the destination path you've read from the 11th column (&DESTINATION_PATH#).  Let me know if that's where you're struggling.  Please share your script code in that case.

    If you're copying the file to another path on the same server, then just add a job that does "cp &FILE# &DESTINATION_PATH#".

    If you're trying to transfer the file to a different agent, then you'll need to add a file transfer job and add code on the Process tab to do a ":put_att FT_DST_FILE="&DESTINATION_PATH#/&FILE#".  (Make sure this file transfer job is configured to generate at runtime.)

    If you're trying to copy the file to multiple destination paths -- one for each row of this file with the destination in the 11th column -- then I would advocate using your script to do a ACTIVATE_UC_OBJECT, passing your &FILE# and &DESTINATION_PATH# variables, to a separate workflow (or at least job or file transfer job) to copy the file.




  • 7.  RE: Script to read the file

    Posted Dec 03, 2024 02:42 AM
    Edited by Juergen Lechner Dec 04, 2024 02:11 AM

    Hi,

    perhaps your understanding is lacking a concrete example.

    The command needed to access a file is (as already mentioned) PREP_PROCESS_FILE. So you simply can access the online documentation for more details. Most of your questions will be answered by the short example found there.

    EDIT: I have overseen some already known information.

    :SET &HND# = PREP_PROCESS_FILE(UNIX01, "/uc4/test.txt",,"COL=DELIMITER,DELIMITER=<TAB>")
    :
    PROCESS &HND#
    :   
    SET &LINE# = GET_PROCESS_LINE(&HND#,11)

    command for a file copy

    :   PRINT &LINE#
    :
    ENDPROCESS

      The command depends on your target

      1. cp / copy for an OS internal copy
      2. JOBF via :ACTIVATE_UC_OBJECT, if the target has an installed OS agent
      3. scp or some file transfer tool (UDM or whatever) to access destinations outside your automation environment.

      But first: Read the documentation page for PREP_PROCESS_FILE!! I personally think that the doc pages for Automic are some of the best (if no THE best) I have ever seen.

      Regards,
      Juergen


      ------------------------------
      Juergen Lechner
      Managing Consultant
      setis GmbH
      Germany
      ------------------------------



    1. 8.  RE: Script to read the file

      Posted Dec 03, 2024 03:46 PM

      Hi Juergen,

      I used this script, which worked for me.

      Thankyou Team,

      Regards,

      Shravya