0 Replies Latest reply on Oct 8, 2019 11:24 PM by Shabeer Madathil

    RunAjobCli using Powershell

    Shabeer Madathil New Member

      Hi,

       

      I want to run one of our taskflow continuously until I finish  all the files in a windows folder. This task can process only one file at a time. Currently i am running this task using 5 mnt infomatica schedule. Usually this task last under 1 minute.

       

      Now I am hoping that I can run RunAjobCli utility inside a loop written in powershell script , this will trigger the infomatica taskflow continuously until I finish my files. But I am not sure how do I call this utility in Powershell.

       

      I have tried calling bat script from powershell loop , but the loop is triggering  the utility all at the same time ( all the instances are throwing error - "The Mapping task failed to run. Another instance of the task is currently running". except one which is finishing successfully after processing one files from the windows folder.

       

      My powershell script

      -------------------------

      write-host "Setting location"

      #Setting location

      Set-Location -Path C:\OPTS\Test

      # checking if the file exist

      $filetocheck = "C:\OPTS\Test\*xml"

      $InfomaticaPath = "C:\Program Files\Informatica Cloud Secure Agent\apps\runAJobCli\"

      if (Test-path $filetocheck)

      {

      #Rename-Item "C:\Testfile.txt" "newname.txt"

      write-host "this file does exist"

      $targDir = "$PWD";

      $filesNames = Get-ChildItem $targDir -Filter *.xml

      #looping through all the files

      $FileCount = 0

      if(Test-path "C:\OPTS\Test\next_to_process.xml")

      {

      write-host "Inside the if checking next to process"

      Remove-Item "C:\OPTS\Test\next_to_process.xml"

      }

      foreach ($filesName in $filesNames)

      {

      $FileCount = $FileCount + 1

      Copy-Item $filesName -Destination "C:\OPTS\Test\Processed" -force

      Rename-Item $filesName "next_to_process.xml"

       

      #Start-Process Run_Optionals_process_changes_orig.bat

      Start-Process "cmd.exe"  "/c C:\OPTS\Test\Run_Optionals_process_changes_orig.bat"

      #write-host $out

      }

      write-host $FileCount

      }

      else

      {

      write-host "this file does not exist"

      }

       

       

      ------------

       

      Bat file code

      -------

       

      cd "C:\Program Files\Informatica Cloud Secure Agent\apps\runAJobCli"

      Echo "This msg inside the batch bat , before the Infmatica call"

      cli.bat runAJobCli -n "UAT_orig" -t MTT -w true

      set return_code=%errorlevel%

      if %return_code% NEQ 0 (

      @echo Error

      goto End)

      End

      exit %return_code%