continuing on error

  • 04 Jun

    Execute Command, continuing on error

    Q: Execute Command, continuing on error. I have a rule which moves a file from one win folder to another win folder and then runs a CMD against it. If the CMD errors out it keeps retrying the file. How do I move the failed file to another folder on the error and NOT retry it with the command line?
    My current setup is:

    • WIN as Source
    • Destinations:
      1. WIN
      2. CMD (Execute Command)

    A: In our latest version v2022.6.2.0 we added a new ‘Redirect ExitCode to PS Integer Var A (%VIA)’ option. Please check the ‘Advanced Tab’ of the CMD (Command) as Destination. Enable this option to transfer the ExitCode to our Pascal Script Integer Var psVIA. We’ll use the psVIA var to move the source file in case the Command returns a value <> 0 (which normally is an errorcode).

    Limagito File Mover continuing on error

    We will need a third ‘Pascal Script’ as Destination.

    1) WIN as Destination
    2) CMD as Destination
    Now please add a third ‘Pascal Script’ Destination. This must be in the last position. Do not forget to adjust the Const ctErrorPath value. This Pascal Script will move the source file to an error path if the ExitCode of the CMD (command) <> 0.

    Limagito File Mover Destination Setup

      ctErrorPath = 'C:\3ProcessError\'; // must end with a /
      psExitCode:= 1;
      // ... add your code here
      If psVIA <> 0 Then
        psMoveFile(psFilePath + psFileName, ctErrorPath + psFileName);
        psLogwrite(1, '', 'CMD ExitCode Error, psVIA: ' + IntToStr(psVIA));
    Limagito File Mover Pascal Script as Destination

    #Filetransfer #Filemanagement

    If you need any info about this ‘continuing on error’ request, please let us know.

    Best regards,

    Limagito Team