AutoSys Workload Automation

Expand all | Collapse all

Export job definitions to Excel

  • 1.  Export job definitions to Excel

    Posted Oct 13, 2016 12:45 PM

    One question we get asked all the time by developers is for a list of what jobs we have in Autosys.  I know that we can easily use autorep to bring up job definitions in text format, but has anyone been able to import that data into a user-friendly format like Excel?  I can't think of any other way to get developers that information using anything in Autosys, other than creating spreadsheets by hand, which is extremely time consuming and prone to human error.



  • 2.  Re: Export job definitions to Excel

    Posted Oct 13, 2016 12:47 PM

    And by the way, by importing, I mean making the data appear in Excel in a horizontal fashion, rather than vertical, which the text file uses.



  • 3.  Re: Export job definitions to Excel

    Posted Oct 13, 2016 01:06 PM

    If no one's been able to do that - then how about importing the current job definitions to excel directly from the Autosys database? If so, what kind of query works?



  • 4.  Re: Export job definitions to Excel

    Posted Oct 13, 2016 06:58 PM

    Using two or three jobs, please provide an example (screenshot) of the preferred format.

     

    Thanks,

    Mark Hanson



  • 5.  Re: Export job definitions to Excel

    Posted Oct 20, 2016 11:51 AM

    I have identified the records that are populated by jobs; and have created a SQL to extract jobs - this extract can easily be copied into excel.

    My first post on CA - so not sure how we correspond outside of communities.

     

    tom



  • 6.  Re: Export job definitions to Excel
    Best Answer

    Broadcom Employee
    Posted Oct 24, 2016 05:20 AM

    Hello

     

    You can extract all job definitions (autorep -j ALL -q ) then tranform the jil to xml and load the xml in excel. Excel will format everything.

    I can send to you the perl script that convert jil to xml. xml should look like this (example with a box and a job):

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!-- Time-stamp: "bibliography.xml   3 Mar 2008 16:24:04" -->
    <dic>
    <objet job="BENCH_BOX1">
    <job_type>b</job_type>
    <condition>v(BENCH_VAR100)=1</condition>
    </objet>
    <objet job="BENCH_BOX1_j1">
    <box_name>BENCH_BOX1</box_name>
    <owner>root</owner>
    <command>echo</command>
    <machine>BENCH2</machine>
    </objet>

    </dic>



  • 7.  Re: Export job definitions to Excel

    Posted Oct 24, 2016 09:10 AM

    Mathieu,

    It would be extremely helpful if you would provide the perl script that converts the jil to xml.

    thank you,

    tom



  • 8.  Re: Export job definitions to Excel

    Broadcom Employee
    Posted Oct 24, 2016 09:44 AM

    Hello

     

    The perl in attachment.  Excel may fail to import the xml if the file has several time the same jil statement fot the same job. Example: for a i5 job type, the job can have several i5_params lines. Same thing for a SAP job.



  • 9.  Re: Export job definitions to Excel

    Posted Feb 23, 2017 04:20 PM

    Unfortunately I know next to nothing about Perl/XML  (don't think we even have Perl installed on our machines yet), so it might be awhile before I can try this. Will keep it handy though, thanks!



  • 10.  Re: Export job definitions to Excel

    Posted Feb 24, 2017 03:53 PM

    Forgot to mention, if there was a way to do it with powershell that'd be great! We're primarily a windows shop, so there's not much linux/unix to play around with.



  • 11.  Re: Export job definitions to Excel

    Posted Mar 22, 2017 03:39 PM

    Thank you so much for this script! I have been trying to figure this out for a long time!  I had to tweak it slightly for our server but it works perfectly!!!



  • 12.  Re: Export job definitions to Excel

    Posted Feb 25, 2017 05:50 PM

    Powershell eh?

    Don't threaten me with a good time!

     

    I took a stab at it. Code below.

     

    Here's what it looks like in action:

    PS C:\code\Powershell> .\jil2xcel.ps1 .\jobs.jil

    PS C:\code\Powershell> dir


    Directory: C:\code\Powershell


    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    -a--- 2/25/2017 4:30 PM 2922 jil2xcel.ps1
    -a--- 2/25/2017 4:16 PM 1753 jobs.jil
    -a--- 2/25/2017 4:30 PM 8533 jobs_201702251641.xlsx


    PS C:\code\Powershell>

     

    jil2xcel.ps1

    #* ------------------------------------------------------------------------- *
    #* *
    #* Copyright (c) 2017 CA. All rights reserved. *
    #* *
    #* This software and all information contained therein is confidential and *
    #* proprietary and shall not be duplicated, used, disclosed or disseminated *
    #* in any way except as authorized by the applicable license agreement, *
    #* without the express written permission of CA. All authorized *
    #* reproductions must be marked with this language. *
    #* *
    #* EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO THE EXTENT *
    #* PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS SOFTWARE WITHOUT WARRANTY *
    #* OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF *
    #* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL *
    #* CA BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR DAMAGE, *
    #* DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE, INCLUDING WITHOUT *
    #* LIMITATION, LOST PROFITS, BUSINESS INTERRUPTION, GOODWILL, OR LOST DATA, *
    #* EVEN IF CA IS EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE. *
    #* *
    #* ------------------------------------------------------------------------- *
    # jil2xcel.ps1

    param (
      [Parameter(Mandatory=$true)][string]$jilFile
    )

     

    function main
    {
      $oldVerbose = $VerbosePreference
      $VerbosePreference = "continue"

      If (!(Test-Path $jilFile)) {
        Write-Verbose "Input file not found: $jilFile. Exiting..."
        exit(127)
      }

     

        # Get JIL and strip comment lines
      $jilDB = Get-Content $jilFile | select-string -pattern "`/`* -------" -notmatch | Out-String

        # Create array of jobs
      $jobs = $JilDB -split 'insert_job: '

        # Create Excel file
      $ExcelObject = new-Object -comobject Excel.Application
      $ExcelObject.visible = $false
      $ExcelObject.DisplayAlerts =$false

      $ActiveWorkbook = $ExcelObject.Workbooks.Add()
      $ActiveWorksheet = $ActiveWorkbook.Worksheets.Item(1)

     

        # Write each job to Excel file
      $Row = 1
      for ($i=0; $i -lt $jobs.Length; $i++) {
        $jobOneLiner =""
        $jobs[$i].split("`r`n") | ForEach-Object {
        $jobOneLiner += "$_ "
        }
          #Write-Host $jobOneLiner
        $ActiveWorksheet.Cells.Item($Row, 1) = $jobOneLiner
        $Row++
      }

        # Save Excel file and clean up
      $scriptDir = (Get-Location).Path
      $date= get-date -format "yyyyMMddHHss"
      $ActiveWorkbook.SaveAs("$scriptDir\jobs_$date.xlsx")
      $ExcelObject.Quit()
      $ExcelObject = $Null

    } # main


    # Entry point
    main

     

    Regards,

    Mark Hanson



  • 13.  Re: Export job definitions to Excel

    Posted Mar 31, 2017 11:51 AM

    Any way to split the "fields" for each job in the JIL become column headers in Excel? i.e. something like below:

     

    insert_job   job_type  command  machine  owner  etc...

    jobA           Cmd         script 1     mch1         ops

    jobB          Cmd          script 1      mch1         ops