I am attempting to call a function from within a perl script that will contact a monitoring program. I am getting compilation errors on this line of code.

 $testmessage = system(/usr/bin/postemsg -S tecserver -r(harmless) -m "(This is a test message)" hostname=(Trapeze) notify_action=email alias_notify=(pbkhk) (Event_Message_Class) (SOURCE));

I am getting the following as output:

Bareword found where operator expected at TDC-fabric-monitor.pl line +172, near "/usr/bin" (Missing operator before bin?) Unquoted string "tecserver" may clash with future reserved word at TDC +-fabric-monitor.pl line 172. Unquoted string "harmless" may clash with future reserved word at TDC- +fabric-monitor.pl line 172. Bareword found where operator expected at TDC-fabric-monitor.pl line 1 +72, near "m "(This is a test message at the end of the script)" hostn +ame" (Do you need to predeclare m?) Bareword found where operator expected at TDC-fabric-monitor.pl line 1 +72, near ") notify_action" (Missing operator before notify_action?) syntax error at TDC-fabric-monitor.pl line 172, near "/usr/bin" Execution of TDC-fabric-monitor.pl aborted due to compilation errors

Is there any way to format the system call so that Perl just passes that call to the outside shell? Should I be using something other than system() to call the postemsg command?

Thanks,

-Bill

In reply to Launching an external command from Perl in Linux by wruehl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.