2

What is the most cross platform way to execute a pPerl script from ant?

Windows does not like the Perl script as the executable. Is there any way other than just running Perl using an OS specific executable and passing the Perl script in as an argument?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Gambit
  • 537
  • 1
  • 5
  • 14
  • Which perl are you using? How are you specifying it in Ant? What is the error that you get? – brian d foy Aug 21 '09 at 22:17
  • For windows, This is perl, v5.8.9 built for MSWin32-x86-multi-thread (with 12 registered patches, see perl -V for more detail) Copyright 1987-2008, Larry Wall Binary build 826 [290470] provided by ActiveState http://www.ActiveState.com Built May 24 2009 09:21:0I I wanted to just specify the perl script as the executable since unix uses the #! and windows has the .pl extension binding. – Gambit Aug 25 '09 at 14:06

3 Answers3

2

Have you considered the ant <exec> command? You can use the os attribute to specify which operating system to use.

The catch would be that you would need a specific call for each known operating system the Perl script will be used on. Its probably safer to do an os check anyway.

John McG
  • 608
  • 4
  • 10
1

Have you tried creating a custom Ant target for calling Perl (let's call it call-perl-script), and the implementation of that task switches to another subtask based on the OS (like call-perl-script-windows, call-perl-script-osx, etc.)?

Something based on this previous question, or this or this?

Community
  • 1
  • 1
Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128
  • I was trying to not do specific os checks. – Gambit Aug 25 '09 at 14:07
  • 1
    There's no way around it. If you want your Ant targets to work on different platforms, when it comes to platform-specific functionality (like launching a process) you're going to have to, at some point, write platform-specific code. What I'm suggesting is wrapping it up nicely. – Shaggy Frog Aug 25 '09 at 19:04
0

Windows does not like the Perl script as the executable.

Either you configure windows to execute .pl files (help ftype, help assoc)

ftype PerlScript=perl.exe %1 %*
assoc .pl=PerlScript

or you run the script through pl2bat (happens automatically if you use ExtUtils::MakeMaker to install script). If you use pl2bat, please examine the resulting file and make sure you're satisfied with the results.

you could also use PAR/pp to create an .exe

yo.
  • 11
  • 1