Operating System - Microsoft
1748047 Members
4662 Online
108757 Solutions
New Discussion

Perl in Windows Environment Help

 
SOLVED
Go to solution
Steven Chen_1
Super Advisor

Perl in Windows Environment Help

Hi,

Being new to perl, I would like to get help with working in windows/dos environment on schedule basis (not execute manually from cmd):

1) do we need a batch file to execute the perl file?
2) does the perl need an extention as .pl?
3) what is the syntac on the first line of perl in windows:

#!C:\perl\bin\perl
or
#!/usr/bin/perl

(not in Unix environment!)

Any help is very appreciated!

Steven
Steve
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Perl in Windows Environment Help

You should associate a .pl extension with perl.exe but that is not necessary. I assume that since you are asking this question under OB2/DP that this is an OB2/DP related question so there are a few things you have to do to make Perl work as a pre/post-exec script.

1) If you have installed Perl under Program Files, I suggest that you uninstall and install it under C:\Perl. This makes life simpler because your scripts and the data specifications don't have to be so careful about correctly quoting pathnames with embedded white space.

2) You actually have to copy 2 Perl files to your %OmniBack% bin directory (and once again, I suggest that you install OB2/DP in C:\OmniBack) so that you don't have to deal with white space. It's much easier to remove and reinstall DP that it is to deal with obscure scripting problems. In any event, you need to copy perl.exe and perl58.dll (or whatever version you are using) to the %OmniBack%\bin directory.

3) Your Perl script(s) also should be installed in the %OmniBack%\bin directory. (C:\OmniBack\bin on my Windows boxes).

4) Edit your data specification and add a line similar to this:

-pre_exec "perl.exe -I C:/Perl/lib -I C:/Perl/site/lib C:\OmniBack\bin\myscript.pl"

to the backup object.

This will execute myscript.pl as a pre-exec.
Make sure that your script explicitly exits with an appropriate return value (e.g. 0 if all is well).

If it ain't broke, I can fix that.