Wednesday, May 16, 2007

[code] Apache handler, Perl, Ruby, CGI

Before I figured out about Apache cgi-script handler, I foolishly thought there was something magical about only Perl could be use as CGI, but couldn't figure out what was controlling that. So I wrote a perl script to call ruby because I stubbornly wanted to use Ruby instead.

Of course now I know that it wasn't perl at all; it was just that Bluehost had .pl defined to use cgi-handler by default, and all I had to do was use the .pl extension and it would have worked (but of course it's better to simply add .rb as another cgi-script extension)

Now I just have a goofy perl script. Well, it was fun.

#!/usr/bin/perl

## This works, but, the system function returns an extra 0 at the end
## $result = system("/home/username/public_html/MyRubyProgram.rb $ARGV[0]");

## This works perfectly. No extra cruff.
open(F, "/home/username/public_html/MyRubyProgram.rb $ARGV[0] |");
while (defined($result = )) {
print $result;
}

exit(0);

No comments:

Post a Comment