1

I have the following exec statement:

    $script_dir = 'C:\Users\mcnall\Documents\main_home\script';

    exec("$script_dir\\exec.pl", "$name", "$func_type", "$func_args");

When reaching this line, the error

Can't exec "C:\Users\mcnall\Documents\main_home\script\exec.pl": No such file or directory at C:\Users\mcnall\Documents\main_home\script\main.pl line 153.

The file definitely exists. When I copy and paste C:\Users\mcnall\Documents\main_home\script\exec.pl from the error above it runs the file as expected, it will just not run it through the script for some reason..

I must be doing something stupid, can someone please give me a tip as to what I am doing wrong?

Miller
  • 34,962
  • 4
  • 39
  • 60
AMcNall
  • 529
  • 1
  • 5
  • 23

1 Answers1

1

As mpapec suggested in the comments, you need to specify perl.exe as your first argument:

exec("C:\\Perl\\bin\\perl.exe", "$script_dir\\exec.pl", ....... );
  • Thanks very much! I used the combination of your answer and mpapec's and its done the job. It seems the main problem was not including the perl argument which is strange because it worked in the past without it. I think the only change was alterning the path from absolute to variable, is this a result of that? – AMcNall Jun 05 '14 at 12:09