PerlToHoudini

From Odwiki

Jump to: navigation, search

Contents

Sending/receiving in PERL

Its possible to take advantage of Houdini's capability to communicate over socket connection to send commands to Houdini. There are several ways to make socket connections in PERL, but here is a simple PERL module to facilitate that connection and communicate with Houdini.

There is a discussion on the PythonToHoudini page which has further conversation about opening sockets which may an interesting read.

The OdWiki Houdini PERL module

  • HOUDINI.pm - This has perldoc documentation in the source file. Type perldoc HOUDINI.pm | less to get nicely formatted paged information.

Example usage

Here is an example of how you could set it up so that you can automatically have every Houdini session ready to communicate with PERL.

test.pl

This is a file you wish to execute. It wants Houdini to execute opls and want to process the result.

#!/usr/local/bin/perl
use HOUDINI;

my $houdini = new HOUDINI;
if( $houdini->{connected} == 0 )
{
  print "Cant continue.\n";
  exit;
}

my $result = $houdini->hcommand("opls\n");
print "from houdini: $result\n";

456.cmd

Add this your 456.cmd to open a unique port everytime you start a Houdini session.

 if( `ishvariable("OPEN_PORT")` == 0 )
   set -g OPEN_PORT = `arg(run("openport -a"),1)`
 endif
 echo "This Houdini session is listening to port $OPEN_PORT, set in \$OPEN_PORT"

Houdini Texport

Now you can execute the PERL script with syntax like:

 Director-> unix test.pl &

Credits

Thanks to the authors of the Python page ([[User::JohnColdrick]]) for some tips!

© 2009 od[force].net | advertise