Click Edit Script to open a resizable editing window in
which to work.
The following perl script example raises two questions:
Is there a need to exit from embedded or external scripts?Is the
exit 0; line needed?
#!/usr/bin/perl
print "hello";
exit 0;
If you are writing scripts that will be used by the Operations
agent, then do not use "exit" to end the script if the script is
embedded inside the policy for this reason:
Whenever a VB or Perl script is embedded (Task type=VB Script or
Perl Script) in a Monitor/Scheduled Task policy such as the example
above, script execution is handled by the Advanced Monitor Agent.
This agent gives the embedded script to the embedded "VB/Perl
Script Engine" for processing. Because this happens in the same
process as the monitor agent, any "exit" call from the script
causes the process itself (opcmona) to abort.
If the script is called by a Scheduled Task policy (Task
type=Command) or Monitor policy (source type=Program), then the
action agent (or monitor agent) creates a separate process for the
external script. In this case, the exit which is called inside the
external script is not propagated to the calling process, because
the script runs in a different process, not in a thread in the same
process.
Consequently, exit should only be used when the script is called
externally, not when the script is embedded inside a
policy.