Automic Workload Automation

Expand all | Collapse all

Read VARA - Write in TXT File

Anon Anon

Anon AnonMar 16, 2018 04:23 AMBest Answer

Anon Anon

Anon AnonMar 16, 2018 11:02 AM

Thomas H

Thomas HMar 19, 2018 02:15 AM

Anon Anon

Anon AnonMar 23, 2018 08:37 AM

  • 1.  Read VARA - Write in TXT File

    Posted Mar 15, 2018 12:00 PM
    Hello there,

    well, i want to read a specific Information out of the VARA
    I want to write that i a text file.

    What i have done so far:

    :   SET &HND03# = PREP_PROCESS_VAR("&VARANAME","WLG_RUNNING_FLAG")
    :   PROCESS &HND03#
    :     SET &RET03# = WRITE_PROCESS(&HND03#,"&SCRIPT_RUNNING_FLAG_PFAD#&SCRIPT_RUNNING_FLAG_DATEI01#",&WSLRUNNINGHOST#,&WSLRUNNINGLOGIN#,OVERWRITE,,,,)
    :     PRINT **************
    :     PRINT &&RET03# &RET03#
    :     PRINT *************
    :   ENDPROCESS

    the &HND03# reads the whole Line out of the VARA.
    the WRITE_PROCESS write the whole Line in the TEXT File, of course.

    BUT i just want him to write the 3 ROW from the VARA with the Key WLG_RUNNING_FLAG

    this is in the VARA:
    WLG_RUNNING_FLAG;C:\temp\;wsl.running;Automic_Prozess_gestartet;Value4;Value5

    i want to write in the text file:    Automic_Prozess_gestartet

    how can i realize that in one JOBS

    i hope you can help me again :)

    Thanks alot

    Kind regards
    Thomas

                 












  • 2.  Read VARA - Write in TXT File

    Posted Mar 15, 2018 01:10 PM
    Hi,

    I am not 100% sure of your requirement - you want to write "Automic_Prozess_gestartet" to the file only?
    nothing else, correct?

    in this case I would use the script command GET_VAR and echo in your OS job...

    cheers, Wolfgang


  • 3.  Read VARA - Write in TXT File

    Posted Mar 15, 2018 02:10 PM


  • 4.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 01:17 AM
    Thank you for the answers.

    Well, in fact my main problem here is to WRITE_PROECESS that single Information from the VARA in a File.
    True, i can just ECHO &RET# > c:\temp\file.txt
    But i want to use Automic Skript because the JOBS is used by Redhat  xyz and Linux xyz.
    The ECHO should work for sure on every OS but still - i would like to be able to do that with Automic Skript to be independent which OS is used.

    My Problem is that the WRITE_PROCESS needs a Data-Sequence. And that can´t be a single Variable (i
    So when i pull out my information with GET_VAR - then i can´t WRITE_PROCESS that in a file.
    To get a Data-Sequence i think i have to use PREP_PROECESS_VAR.
    But the PREP_PROCESS_VAR is not able to Get one exakt Column. It always pulls out the whole "line" From KEY to Column 1-5. So the WRITE_PROCESS always writes in my text file the whole VARA "Line" - Starting with KEY;Column1;Column2;Column3;Column4;Column5

    Maybe there seems no other way then to GET_VAR my explicit Column3 and then i echo that with the OS in a File :)










  • 5.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 01:59 AM

    Hi Thomas

    Checkout my marketplace solutionhttps://marketplace.automic.com/details/vara2csv-csv2vara

    Regards
    Joel



  • 6.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 04:03 AM
    Good Morning,

    If Joels' Solution does not fulfill your needs there is of course another solution using script :-)

    You can use GET_VAR to catch your Value "Automic_Prozess_gestartet"
    And yes You are right, for write process you need a process.

    Solution: we create one with : CREATE_PROCESS ;-)
    then you can use : PUT_PROCESS_LINE to set your Scriptvariable containing "Automic_Prozess_gestartet"
    and then you can use WRITE_PROCESS

    https://docs.automic.com/documentation/webhelp/german/ALL/components/AE/11.2/All%20Guides/help.htm#ucacwt.htm%3FTocPath%3DAutomation%2520Engine%2520Script-Leitfaden%7CFunktionelle%2520Gliederung%7CDatensequenzen%7C_____3

    cheers, Wolfgang




  • 7.  Read VARA - Write in TXT File
    Best Answer

    Posted Mar 16, 2018 04:23 AM
    Here is a short example:

    ogt98zm1sbny.jpghttps://us.v-cdn.net/5019921/uploads/editor/rv/ogt98zm1sbny.jpg" width="902">

    cheers, Wolfgang


  • 8.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 07:15 AM
    Thomas Hartmann said:

    True, i can just ECHO &RET# > c:\temp\file.txt
    But i want to use Automic Skript because the JOBS is used by Redhat  xyz and Linux xyz.
    The ECHO should work for sure on every OS but still - i would like to be able to do that with Automic
    I'm all for platform indenpendent coding (many kudos to you for the thought), but echo and output redirection is practically one of the most basic POSIX things there is. I'd probably rest assured that this will work, and continue to work, across any UNIX-like OS, and any Windows version of the forseeable future. Of course, the semantics of the file would be different: c:\temp would not work on Linux. So you'd need to parameterize the filename.

    However, you could also look into generic jobs. While they have some quirks, they pretty much let you define one command for Linux and one for Windows, and select the appropriate command based on the Agent in question.

    Hth,
    Carsten


  • 9.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 08:43 AM

    Carsten - do you want to ecape values containing ' , ", ``, $() or $ (etc.) during "echo"-ing?

    ...else you might end up with...

    :SET &TROUBLE# = "`rm -f ~/*`"
    echo "&TROUBLE#" > /tmp/somewhat.txt

    My CSV2VARA solution is using the WRITE_PROCESS way.



  • 10.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 08:52 AM
    Joel Wiesmann said:

    Carsten - do you want to ecape values containing ' , ", ``, $() or $ (etc.) during "echo"-ing?

    ...else you might end up with...

    :SET &TROUBLE# = "`rm -f ~/*`"
    echo "&TROUBLE#" > /tmp/somewhat.txt

    My CSV2VARA solution is using the WRITE_PROCESS way.

    Valid point. BUT in my defense, since OP said "specific information out of a VARA", one could probably assume that his input is sanitized.

    But yes, your solution may account for that more than "echo".


  • 11.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 09:06 AM
    Wolfgang Brueckler said:
    Here is a short example:

    ogt98zm1sbny.jpghttps://us.v-cdn.net/5019921/uploads/editor/rv/ogt98zm1sbny.jpg" width="902">

    cheers, Wolfgang
    Thank you ! That does the trick :smile:
    You even showed me a great way to create my own Data_Process ... seems simple now but without you it wasn´t as easy as now :blush:
    Great!!!


  • 12.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 09:38 AM
    You are welcome :-)

    You owe me a Cuba Libre without coke :-)


  • 13.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 09:45 AM

    You owe me a Cuba Libre without coke :-)
    He's a pirate, you know :)


  • 14.  Read VARA - Write in TXT File

    Posted Mar 16, 2018 11:02 AM


  • 15.  Read VARA - Write in TXT File

    Posted Mar 19, 2018 02:15 AM
    B)  :D


  • 16.  Read VARA - Write in TXT File

    Posted Mar 19, 2018 09:58 AM
    I have one more Question :)
    Your Example shows how to write the own created handle in a text file - but how can i put out the handle in a process line?
     i24qdnw1s879.pnghttps://us.v-cdn.net/5019921/uploads/editor/kk/i24qdnw1s879.png" width="511">
    (For better copy&paste)
    ! Set my own Value
    :SET &VALUE1         =  "Im;going;for;script;course;soon"
    ! Create a new process
    :SET &HND#           = CREATE_PROCESS(NEW)
    ! Put values in it
    :SET &RET            = PUT_PROCESS_LINE(&HND#,"&VALUE1", ";")
    ! Now - just Print it out
    :PROCESS(&HND#)
    :  SET &TESTVALUE#  = GET_PROCESS_LINE(&FIRMEN_HND#)
    :  PRINT &TESTVALUE#
    :ENDPROCESS
    :CLOSE_PROCESS &HND#


    The reason is that i ask the User to select different options. Depending of his selection i want to create a loop which process some jobs.
    Pretty simple - i am used to VBScript and i miss some simple Loop Options in Automic Script - im looking for a course this year ;)


  • 17.  Read VARA - Write in TXT File

    Posted Mar 19, 2018 10:22 AM
    Hi

    I am afraid I do not understand: Your Example shows how to write the own created handle in a text file - but how can i put out the handle in a process line?

    I assume (!) your question is how to get the whole content of the Handle, correct?
    My (and your) example consist of only one data line!

    everytime you call PUT_PROCESS_LINE(&HND#,"&VALUE1", ";") adds one line to your handle.

    Basically you can use the WHILE Script function:
    https://docs.automic.com/documentation/webhelp/german/ALL/components/AE/11.2/All%20Guides/help.htm#ucaaed.htm%3FTocPath%3DAutomation%2520Engine%2520Script-Leitfaden%7CFunktionelle%2520Gliederung%7CScript-Aufbau%2520und%2520-Prozessierung%7C_____26

    So the easiest way creating a loop in Automic script would be using a counter.

    hope this answers your question, if not pls let me know :-)

    cheers, Wolfgang




  • 18.  Read VARA - Write in TXT File

    Posted Mar 19, 2018 10:30 AM
    Hi,

    its not easy to explain in english :)
    i could have opened that request in german - i know :D

    i have, for example, three companys.
    CompanyA
    CompanyB
    CompanyC

    I aske the user if he wants to copy a File to all Companys or just to A;B;C

    On my Fileserver i have folders like:

    C:\temp\CompanyA
    C:\temp\CompanyB
    C:\temp\CompanyC

    He selectes Company A and C

    So - i need something like an array where i put A and C in

    Now - i need a handle/process/... to run over that "array"

    i want to start JOBF.COMPANY_FILE two times.
    Everytime some Values Change - like in this example "A" and "C" for
    C:\temp\Company&CMPSELECTED

    I hope that example explains better my needs :)
    And - thank you for your time !!


  • 19.  Read VARA - Write in TXT File

    Posted Mar 19, 2018 01:13 PM
    Ah its clearer now :-)

    In and with automic you have several ways to accomplish your requirement. Most times. Often. If there's no bug.

    I suppose you want to use Promptsets with checkboxes - they return an array where your users can select with  checkboxes the values they want.

    And *Schubiduba* Automic Script knows Arrays :-)

    here is a short example - think its a good start for you.
    A String is created with Semikolon as Seperator and passed to an Array.
    then in a loop all values are read from the array and printed to the Report.

    ! Creating String
    :SET &STRING# = "Schubiduba;Oleole;Heureka;Auweh;"

    ! Array Definition
    :DEFINE &ARRAY#, string,5
    !Pass String to Array - ; as Seperator
    :FILL &ARRAY#[] = STR_SPLIT(&STRING#,";")

    !Init of counter (german: Zählvariable)
    :SET &ZVAR# =1
    :SET &ZVAR# = FORMAT(&ZVAR#,"00")
    ! detecting length of whole array
    :SET &ARR_LEN# = LENGTH(&ARRAY#[])

    :WHILE &ZVAR# < &ARR_LEN#
    :SET &ZVAR# = FORMAT(&ZVAR#,"00")
    :  PRINT "Element &ZVAR# = &ARRAY#[&ZVAR#]"
    :  SET &ZVAR# = &ZVAR# + 1
    :ENDWHILE

    important hint: Arrays can not be created with a dynamic size - means you can not use a script variable for the size definition of the Array, it must be a "real" number!

    If you have any questions, let me know.

    cheers, Wolfgang



  • 20.  Read VARA - Write in TXT File

    Posted Mar 23, 2018 08:12 AM
    You did it again  B)
    Thank you very much!
    I cant wait for the Script Course :smiley:


  • 21.  Read VARA - Write in TXT File

    Posted Mar 23, 2018 08:37 AM
    You 're welcome :-)