Thanks for the suggestion Thomas.  Its working fine now.  <br><br><div class="gmail_quote">On Wed, Jan 28, 2009 at 6:56 PM, Thomas Guyot-Sionnest <span dir="ltr"><<a href="mailto:dermoth@aei.ca">dermoth@aei.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<div class="Ih2E3d"><br>
shadih rahman wrote:<br>
> Can someone please give me an example how to submit external command<br>
> using perl script.  I am trying to do this and its now working.  The<br>
> command I am passing to named pipe is something like this.  Thanks<br>
> "ACKNOWLEDGE_HOST_PROBLEM;<br>
> hostname;1;1;1;1;sr2690;testing<br>
> "1233162775<br>
><br>
><br>
> my code is like this.<br>
><br>
><br>
> #!/usr/bin/perl<br>
> #use strict;<br>
> #use Getopt::Long qw(:config no_ignore_case);<br>
> use warnings;<br>
> use Data::Dumper;<br>
><br>
> use Getopt::Long ;<br>
><br>
> my ($action, $host, $service, $username, $comment, $HELP);<br>
> my $now=`date +%s`;<br>
> chomp ( $now );<br>
<br>
</div># Easier/portable (you could also call time() directly in the printf<br>
below instead of using a variable):<br>
<br>
my $time = time()<br>
<div class="Ih2E3d"><br>
> my $commandfile='/var/log/nagios/rw/nagios.cmd';<br>
><br>
> open CF, ">$commandfile" or die $!;<br>
<br>
</div>I'd suggest opening the pipe only when you want to write to it, or at<br>
least after parsing the arguments. Ex. you could open and close it in<br>
the send_to_named_pipe function.<br>
<br>
><br>
> [...]<br>
<div class="Ih2E3d">><br>
> sub send_to_named_pipe {<br>
>   my ($command )  = @_;<br>
>   chomp ( $command );<br>
><br>
>   if ( defined ( $command ) ) {<br>
>     print CF "\"$command\n\"$now";<br>
<br>
</div># I guess you meant something like this:<br>
printf CF "[%i] %s\n", $now, $command;<br>
<br>
><br>
> [...]<br>
><br>
<br>
Anyhow, if you're still stuck try outputing to a standard file, then<br>
compare the lines you get with known working commands.<br>
<br>
<br>
- --<br>
Thomas<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.7 (MingW32)<br>
Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org" target="_blank">http://enigmail.mozdev.org</a><br>
<br>
iD8DBQFJgKpc6dZ+Kt5BchYRAq2eAJ9L+1+ssz+ntkmGFRY/mrbD2XLdQgCgpZGl<br>
qCsSxMrK30Kg6ydRqDwGefQ=<br>
=eRMt<br>
-----END PGP SIGNATURE-----<br>
<br>
------------------------------------------------------------------------------<br>
This SF.net email is sponsored by:<br>
SourcForge Community<br>
SourceForge wants to tell your story.<br>
<a href="http://p.sf.net/sfu/sf-spreadtheword" target="_blank">http://p.sf.net/sfu/sf-spreadtheword</a><br>
_______________________________________________<br>
Nagios-devel mailing list<br>
<a href="mailto:Nagios-devel@lists.sourceforge.net">Nagios-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Cordially,<br>Shadhin Rahman<br>