Automic: How to implement Error-Handling in Script

509 Views Asked by At

I want to check a file in Unix via Automic. If the file doesnt exist it should switch the host and check if the file is there. The problem is, that I dont now how to implement a error handling. Everytime the script object is processing and cant find the file the skript aborted. I need a new starting point in the skript but "ON_ERROR" or ":RESTART" doesnt work.

How can I implement a logic like this: IF the script aborted due to the error-massage 'No such file or directory'start the script from here instead.

Thank you very much for your help! Best regards

2

There are 2 best solutions below

0
On

I have solved it. Use the function PREP_PROCESS_FILENAME to check if the file exists in the folder!

0
On

You have to start the task twice in the same workflow. The task-job checks if the script exists otherwise nothing to do.

if [ -f "/path/to/script" ]
then 
   bash /path/to/script
else
   echo "Script not found"
fi

In Post-Script you can modify the state for the empty task with :MODIFY_STATE. Depend on report or returncode