AMcNall
AMcNall

Reputation: 529

How to call a script in a subdirectory from Perl using system (Windows)

I have a base directory, call it MAIN and two subfolders, SCRIPTS and WORK. When using the following line of code, the script calls upon the job and runs it, only if job_name is in the MAIN folder, then prints output or error to job_name.out/.err in the WORK folder.

system("$job_name > ./WORK/$job_name.out 2> ./WORK/$job_name.err");

If I move the jobs into SCRIPTS then I cannot seem to find an efficient/simple way to call upon it.. I figured something similar to the following code would work:

system("SCRIPTS/$job_name > ./WORK/$job_name.out 2> ./WORK/$job_name.err");

But I get errors like:

How can I compose this command to get it to work from a subdirectory?

Upvotes: 1

Views: 594

Answers (1)

Zaid
Zaid

Reputation: 37146

On Windows, filepaths are specified with backslashes (\).

Instead of system("SCRIPTS/$job_name"...), try system("SCRIPTS\\$job_name"...)

Upvotes: 3

Related Questions