Help hooking up PerlScript

This forum is for discussing Mailtraq's Scripting features. Get help with Mailtraq scripts, templates and external ActiveX scripting.

Help hooking up PerlScript

Postby Martin Clayton » Fri Jan 26th, 2007 10:52am

Hi,

How can I get PerlScript to recognise Mailtraq's Server Object? Eg, what would be the equivalent of Javascript's var software = Server.Software;

Code: Select all
<@LANGUAGE=PerlScript@>
<HTML>
<TITLE>PerlScript test</TITLE>
  <BODY>
    <%
      use warnings;
      $Response.Write("<h1>Hello World!</h1>\n");
      $software = Server.Software;     
      $Response.Write($software . "<BR>\n");   # returns string "ServerSoftware"
    %>
  </BODY>
</HTML>


Thanks for any pointers.

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK

Re: Help hooking up PerlScript

Postby Martin Clayton » Fri Feb 02nd, 2007 8:28am

Martin Clayton wrote:How can I get PerlScript to recognise Mailtraq's Server Object?

Hmmm, borrowing some words from one of Jim's standalone perl scripts I see it can be done like this:
Code: Select all
<@LANGUAGE=PerlScript@>
<HTML>
<TITLE>PerlScript test</TITLE>
  <BODY>
    <%
      use warnings;
     
      # load modules
      use Win32::OLE;
       
      $mtq = Win32::OLE -> new('Mailtraq.Control');
      die "Error: ", Win32::OLE -> LastError(), "\n" unless $mtq;
       
      $software = $mtq -> Server -> Software;
      die "Error: ", Win32::OLE -> LastError(), "\n" unless $software;
       
      $output =  $software . " says Hello World!";
       
    %>
    <H1><% $Response.Write($output); %></H1>
  </BODY>
</HTML>


Is the Win32::OLE Control the only way or is there a more direct method (perhaps where perl doesn't need to be installed)?

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK

Re: Help hooking up PerlScript

Postby Elric Pedder » Fri Feb 02nd, 2007 4:08pm

Martin Clayton wrote:How can I get PerlScript to recognise Mailtraq's Server Object? Eg, what would be the equivalent of Javascript's var software = Server.Software;

Could you try
Code: Select all
    $software = Server.Software();
just to see if it makes any difference?

I haven't had much success with Perlscript, even though the ActiveX Scripting Host should be language-neutral. However I did once find that Perlscript only expected properties to be type-library declared, not methods. Since ActiveX Scripting doesn't differentiate between properties and methods, the above might give a different outcome.
Mailtraq Development and Escalation Support
Novitraq Incorporated
User avatar
Elric Pedder
Mailtraq Escalation Support
 
Posts: 2675
Joined: Tue Nov 23rd, 2004 1:16pm
Location: Montreal, Canada

Re: Help hooking up PerlScript

Postby Martin Clayton » Sat Feb 03rd, 2007 1:11pm

Hi Elric,
Elric Pedder wrote:Could you try
Code: Select all
    $software = Server.Software();
just to see if it makes any difference?

Indeed it does, thanks.
Code: Select all
$software = Server.Software;      # -> "ServerSoftware"
$software = Server.Software();    # -> "ServerMailtraq"
$software = $Server.Software;     # -> "Software"
$software = Server().Software();  # -> "Win32::OLE=HASH(0x7d209ec)Mailtraq"
$software = $Server.Software();   # -> "Mailtraq"


However I did once find that Perlscript only expected properties to be type-library declared, not methods. Since ActiveX Scripting doesn't differentiate between properties and methods, the above might give a different outcome.

Useful pointers -- thanks.

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK


Return to Mailtraq Scripting

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron