General
cancel
Showing results for 
Search instead for 
Did you mean: 

Perl Help in Windows Environment

SOLVED
Go to solution
Steven Chen_1
Super Advisor

Perl Help in Windows Environment

Being new for Perl, I would like to seek help about using it on Windows platform:

1) what should the 1st line be in *.pl file:
#!/usr/bin/perl
or

#!C:\perl\bin\perl
or

the combination?

2) how to execute perl on schedule, not from cmd manually. could that be:

a) xxx.bat
b) inside xxx.bat --> perl replicate_auto.pl?

Any help is greatly appreciated!

Steven

Steve
3 REPLIES
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Perl Help in Windows Environment

You should note that the "shebang" syntax has no meaning in a windows environment (unless you are running SFU -- Microsoft Services for UNIX --- and are running under a UNIX-like shell). Because it begins with '#', it is treated as a comment by Perl. I just leave my scripts as:
#!/usr/bin/perl -w so that they work as intended in UNIX land. Windows handles the association of a file to an executable in an entirely different way. Windows uses filename extensions (e.g. .pl) to automatically associate .pl files with Perl.exe. In UNIX, filename extensions are absolutely meaningless except for conventions and except for any associations that might be built into an application.

In Windows:
My Computer -> Tools -> Folder Options ->File Types is where the .pl to Perl association is done although that is typically is done for you when Perl is installed.

If you need to execute Perl in a cron-like manner then you need to use a cron-like tool. Pick one and use it.

You also asked this question in the OmniBack/Data Protector forum and there are some special rules for using Perl as a pre/post-exec command. See my response there.
If it ain't broke, I can fix that.
curt larson_1
Honored Contributor

Re: Perl Help in Windows Environment

windows uses file associations based on the filename extentions, i.e. if you have your file associations set up right all you need is the .pl at the end of the file name for windows to know it is a perl file

#! is just another comment on windows

a .bat file is not necessary, but it is nice to use because you can redirect the output to log file such that you can review any error messages that might have occured
spex
Honored Contributor

Re: Perl Help in Windows Environment

Hi Steven,

To address your second question: I would create a batch file that executes your perl code (e.g. "perl.exe foo.pl"). If you associate '.pl' files with 'perl.exe', you won't need the batch file. Then create a Scheduled Task.

Start->Settings->Control Panel->Scheduled Tasks->Add Scheduled Task

PCS