Im doing a simple script to install java. The script succeeds at "Then". Where can I see which Then its stopping on?
I put in a bunch of steps to send an email in each if/else so I can see what the script is doing but its not sending me any emails. I do know emailing works as a couple other scripts are working fine.
Im trying to 1. Test is java exists on the machine. If not send and email saying no java on this machine.
2. If java exists test if its 8-151 if not install 151. If it has 151 send an email saying it already has 151.
Im using /nul to test if a folder exists. Is this still a valid method?
Anybody see any glaring errors in this procedure?
yhassell , I don't see anything obvious with the script, but consider putting some "writeProcedureLogEntry" commands at each step so you can trace what is happening. You can review those in the Agent Procedure log, and try to see what is going on.
The \nul should work, but if you could identify a real file that should be there, that would be a better test. I.e. you could dig down to ...\bin\java.exe
Thanks Chris. I did add some writeprocedurelogentry lines and that has helped. Seems the /nul is working. I cant dig to a file because I dont know what version of Java they are currently on and in java's infinite idiotcracy (not sure thats a word) they change the folder name of each new release...
note that with continueonfail set to false, your scripts may never complete the logging step, since the script is halted if there's any error, as soon as that error happens.
to debug, set continueonfail to true.
Continue on Fail isn't just for debugging (anymore) :)
You sometimes need to consider the action you're taking when you set this flag.
When I create new scripts, I usually set Halt on Fail - but - I look for certain commands that are allowed to fail. For example, I write a default configuration file (halt on fail) then try to write a custom config file to override the default. It may or may not exist. If it doesn't, the writeFile will fail, so I set Continue on Fail for that one command.
This may not be "good programming", but Kaseya agent procedures don't allow you to check the presence of a file ON the Kaseya server before you copy it - the checks reference the agent file system. Thus, you only have the option to "blind copy". In my example, I halt if the required (default) file isn't copied, but continue merrily on my way if the optional override file isn't copied.
If I'm struggling with a procedure that doesn't complete, I usually add a writeProcedureLogEntry before and after the suspected command, and enable Continue on Fail for the suspected command(s). As Craig pointed out, you need the Continue on Fail to see any remaining messages in the log.
You can force a procedure to halt with a failure at a specific point by issuing a getFile command, requesting a file you know doesn't exist (C:\nowhere\nothing.xyz) and setting Halt on Fail. This can be handy in troubleshooting by causing the procedure to stop at specific points in the logic.
IT might be failing at the execute procedure step. Does the user have access to the network share where your file is located at?