Start a Conversation

Unsolved

This post is more than 5 years old

S

4812

March 27th, 2009 07:00

invoke perl script using script notifier adapter

Hey guys, guess this is too lame for the developer section, but i've tried so long unsuccessfully to invoke a simple perl script via sm_notify. Btw, the mail notifier adapter i got even working,  makes me think i'm not too stupid ;o) to understand. I did the following:

wrote a simple perl script "test.pl":

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

#!/usr/bin/perl

foreach (@ARGV) {
  print "$_\n";
}

$file = 'file.txt';
$text = "just a text";

open(HANDLE, ">file.txt") or die("$!\n");
print HANDLE $text;

close(HANDLE);

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

which is located in /opt/InCharge72/SAM/smarts/local/actions with full permissions (also the directory is granted writing permissions)

Then changed the config files:

/opt/InCharge72/SAM/smarts/local/conf/notifier/script-notify.conf:

    serverName = "OURSERVER"

    scriptName = "test.pl"

/opt/InCharge72/SAM/smarts/local/rules/notifier/script/script-filter.asl (kept default)

/opt/InCharge72/SAM/smarts/local/rules/notifier/script/script-custom.asl (kept default)

Now i start the Notifier Adapter via:

[root@smarts1 bin]# ./sm_notify --output --confdir=/opt/InCharge72/SAM/smarts/local/conf/notifier/ --conf=script-notify.conf script

The little server remains running, the log file only shows:

InCharge Server OURSERVER has connected.

However, it looks like the script was not invoked because the file.txt was not created (which is the task of the script) and the output (print HANDLE $text; ) - i dont even know in which terminal to expect it :l

If this would work, the documentation anyway lacks about passing the arguments.. If someone could help me, it would be great, as you can see i am a beginner. I thought about trying to get deeper in ASL, but i guess it shouldnt be necessary for that?!

Thx, Stephan

53 Posts

March 31st, 2009 11:00

Stephan,

Does your script work correctly when run maually?

Have you searched for "file.txt" in case you are not correct about the CWD of the script when launched?

Have you run your sm_notify with debug and tracing on?

You can also try putting the full path name of your script into the conf file. I know the actions directory is definately used for ACT_Script objects, but not for sure about the notifier.

- TC

7 Posts

April 6th, 2009 08:00

Hi TC,

i solved the issue, the script has been run all the time! But this happened in /opt/Incharge/SAM/smarts/bin - because sm_notify runs in this directory, no matter where the script is located. Thx for ur efforts!

Stephan

15 Posts

February 18th, 2010 10:00

Can this be adapted to push a batch file or script to run on a client?

37 Posts

February 18th, 2010 21:00

Thanks a lot guys. As a beginner, this is really a new information for me.

So can somebody please explain the usage of script-notifier.conf? How can we use that? The scenarios? How to use that?

Many thanks

Arun

No Events found!

Top