<p>Microsoft has a port of sendmail available on their FTP site at <a class="doc" href="ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/sendmail/">ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/sendmail/</a></p>
<p>A commercial sendmail product is available from MetaInfo, Inc. An
evaluation version is available at <a class="doc" href="http://www.metainfo.com/">http://www.metainfo.com/</a></p>
<p>Another commercial mail product is wrmail, part of the slmail product
from Seattle Labs. A free version is available at <a class="doc" href="http://www.seattlelab.com/">http://www.seattlelab.com/</a></p>
</dd>
</dl>
<h2><a name="How_do_I_schedule_jobs_on_Win32_">How do I schedule jobs on Win32
platforms?</a></h2>
<p>The UNIX cron utility doesn't exist on Win32 platforms.</p>
<p>For Windows 2000, there is a scheduling application available. It can be accessed through the
Start menu: <code>Start | Settings | Control Panel | Scheduled Tasks</code>. By clicking "Add Scheduled Task", you
start the Scheduled Task Wizard which walks you through the process.
<p>For Windows NT, a scheduling tool called <code>AT</code> is available. Unlike
the UNIX cron utility, <code>AT</code> doesn't store its schedule in a flat
file, but is configured using command-line arguments. Note the AT command seems
to be very picky about syntax. Here is one example:</p>
<pre> at 23:37 /interactive /every:M,T,W,Th,F,S,Su cmd /c "c:\perl\bin\perl.exe c:\test.pl"
</pre>
<p>If you don't like the command-line version of <code>AT</code>, there's a GUI
version, WinAT, which is available with the Windows NT Resource Kit. The
"Schedule" service must be running when your job is supposed to
happen.</p>
<p>Note that you may have problems when running AT or WinAT if the scheduled
program or script requires any special rights or permissions other than those
held by "System" (ie, if it is working across computers or NT
domains). This is because NT does not properly allow you to run preinstalled NT
services, such as the "Schedule" service as a user with network
priveleges. It may <i>look</i> like you can set the scheduler to login as a user
with network priveledges, but the service just does not recognize that user's
right's and permissions and the System userid has only local permissions.</p>
<p>An all-Perl cron-like solution exists at <a class="doc" href="http://www.megadodo.demon.co.uk/perl/">http://www.megadodo.demon.co.uk/perl/</a>
which uses a familiar Unix-like crontab file. This script can be ran as an NT
Service (see <a class="doc" href="#What_is_a_Windows_NT2000_service_">How do I set up a Perl
script as an NT Service?</a>). When you create your own NT service, NT lets you
set the useid/password pair, and these services do recognize that userid's
rights and permissions. Hence, the scheduled program or script will have the
necessary rights.</p>
<p>There are a few commercial cron-like schedulers. NTcrond, is available from
ifdef software: <a class="doc" href="http://www.ifdef.com/">http://www.ifdef.com/</a> and
AutoTask2000 is available from <a class="doc" href="http://www.cypressnet.com/">http://www.cypressnet.com/</a>.
These programs <i>should</i> recognize the rights and priveleges of the userid
you set their service to run under to enable the scheduled program or script to
have the necessary rights.</p>
<p>For Windows 9x, there's a System Agent available with the Microsoft Plus!
Pack. Also, there are several shareware scheduling utilities, notably LaunchPad
and Metz Scheduler. These can be found on a good shareware search engine, such
as <a class="doc" href="http://www.shareware.com/">http://www.shareware.com/</a>. There is
also an optional "Task Scheduler" component with IE4.01 and Windows
98.</p>
<p>Because scheduled jobs on Windows NT run as a service (see <a class="doc" href="#What_is_a_Windows_NT2000_service_">What
is a Windows NT service?</a>), you need to take special steps to make sure that
files and environment variables are available to your script.</p>
<p>In some instances, Perl's internal <code>sleep</code> function might be an
appropriate means of scheduling. For example:</p>
<pre> $seconds = 180;
sub action;
while(1) {
&action;
sleep($seconds);
}
</pre>
<p> </p>
<h2><a name="Where_can_I_find_Win32_ports_of_">Where can I find Win32 ports of
UNIX tools?</a></h2>
<p>You might want to take a look at the help file for Windows NT and Windows 9x
commands to see if there's a rough equivalent distributed with your Win32
platform. If not, try one of these URLs:</p>
<ul>
<li>
<p>Cygwin - Linux-like environment for Windows, contains many GNU tools, as well as a complete
development environment. <a class="doc" href="http://www.cygwin.com/">http://www.cygwin.com/</a></p>
</li>
<li>
<p>Virtually Un*x! - various ports of UNIX programs for Win32. <a class="doc" href="http://www.itribe.net/virtunix/">http://www.itribe.net/virtunix</a></p>
</li>
</ul>
<p>There are also several UNIX-like tools available in the Windows NT Resource
Kit. Also, there are several UNIX-to-Win32 commercial packages available,
including the MKS Toolkit from Mortice Kerns Systems, Inc.: <a class="doc" href="http://www.mks.com">http://www.mks.com/</a>.
<p>You can also check into the Perl Power Tools, being developed under the UNIX
Reconstruction Project. Here you can find UNIX tools that are being
reimplemented into all Perl. You can see the latest at <a class="doc" href="http://language.perl.com/ppt/">http://language.perl.com/ppt/</a></p>
<h2><a name="What_is_a_Windows_NT2000_service_">What is a Windows NT/2000 service?</a></h2>
<p>On Windows NT/2000, a service is a special kind of executable program that runs in
the background. Services are used for programs that are constantly working, such
as network protocols or database servers. Most WWW servers on Windows NT/2000 are
implemented as services.</p>
<p>A service is different from other programs in several ways:</p>
<ul>
<li>
<p>Services aren't run interactively, although the <code>NET START</code>
and <code>NET STOP</code> commands can be used to start or stop a server.
The Services control panel is used to start, stop, or pause a service.</p>
</li>
<li>
<p>Services don't act with the authority of the logged-in user. That means
that services can't see user environment variables or read files that are
readable only by the logged-in user. You can set the account that a service
uses in the Services control panel.</p>
</li>
<li>
<p>Services run even when no one is logged in to the machine.</p>
</li>
</ul>
<p>The most important thing to remember is that you have to take special steps
to make resources available to services. In general, you need to make files
available to the Everyone group, and you have to have environment variables
(like <code>PATH</code>) be system environment variables.</p>
<h2><a name="How_do_I_run_a_Perl_script_as">How do I run a Perl script as a
Windows NT Service?</a></h2>
<p>You can run your Perl scripts as Windows NT Services via a program called
srvany.exe, which comes with the Windows NT Resource Kit. Once srvany.exe is
installed, read the srvany.wri file which should be with it. This document will
explain how to set up registry entries for your new service.</p>
<p>After you are set up, to run your script as a service do:</p>
<pre> x:>srvany perl script.pl
</pre>
<h2><a name="How_do_I_run_a_Perl_script_as_2K">How do I run a Perl script as a
Windows 2000 Service?</a></h2>
<p>You can run your Perl scripts as Windows 2000 Services by accessing the Microsoft
Management Console. The Windows 2000 help files contain plenty of information on how to
start the MMC and how you can use it for Perl scripts.
<h2><a name="How_do_I_set_permissions_on_a_fi">How do I set permissions on a
file?</a></h2>
<p>Win32 platforms don't have the same mechanisms for setting permissions on
files as UNIX does. For files on FAT partitions (which means all files in
Windows 9x), you don't have to set permissions explicitly on a file. All files
are available to all users.</p>
<p>For files on an NTFS partition on Windows NT, you can set the security
permissions on a file using the Explorer and the properties sheet of the file.
Right-click the file in Explorer, and choose Properties from the drop-down menu.
Select the Security tab, and click Permissions to set the Permissions on the
file. Click Help for more information.</p>
<p>A command-line program, <code>CACLS</code>, will also change the permissions
on a file. For more details, type <code>HELP CACLS</code> on the command line.</p>
<p>Windows 9x/98 machines that are administered using Novell can have accounts
and permissions similiar to NT. However, these permissions must be set up by the
Novell administrator.</p>
<h2><a name="How_do_I_associate_Perl_scripts_">How do I associate Perl scripts
with perl?</a></h2>
<p>On Windows systems, association is the process of specifying which programs
should be used for which kind of files. Files are grouped into file types, such
as JPEG files or Perl scripts. The file type of a file is identified by its file
name extension (all the letters after the last ".'' in the file name).</p>
<p>So, for example, we can say that there's a type of file called a text file,
which has the file extension <em>.txt</em>, and which is handled by the Notepad
program.</p>
<p>Usually, ActivePerl programmers create a file type like Perl Script and
associate the extension <em>.pl</em> with that type. We specify that the perl
interpreter binary, <em>perl.exe</em>, is responsible for that file type.
Several Web servers require that you associate your scripts with <em>perl.exe</em>
before the script can be run.</p>
<p>On Windows 2000, you can create a new file type and associate it with the perl
intepreter with it as follows:
<ol>
<li><p>Double-click on the My Computer icon.</p></li>
<li><p>From the Tools menu, choose Folder Options. This opens the Folder Options
dialog box.</p></li>
<li><p>Choose the File Types tab. This gives you a list of file types currently registered
(or already associated in Windows 2000).</p></li>
<li><p>Click the New button.</p></li>
<li><p>In the File Extension box, type "<code>pl</code>" and click OK.</p></li>
<li><p>Click the Advanced button. This opens the Edit File Type window.</p></li>
<li><p>Click the New button. This opens the New Action dialog box. Type "<code>Open</code>"
in the Action window (as you would want the Perl files to be "opened" by the Perl interpreter).
Then, either type the full path of the location of the Path interpreter in the Application window, or
click the Browse button to select the executable file of the Perl interpreter.</p></li>
<li><p>Click OK to close the New Action window. You can click the Change Icon button, if you want to
find an icon to match the file type. When you click the Change Icon button, you are given a selection of
pre-set icons or you can browse to a different location. If you want to use a Perl icon for the .pl files, browse
to the folder where the Perl interpreter is located, choose the Perl interpreter and click Open. Then click OK
to close the Change Icon Window.</p></li>
<li><p>Click OK to close the Edit File Type window.</p></li>
<li><p>Click Close to close the Folder Options window.</p></li>
</ol>
<p>On Windows 9x and Windows NT 4.0, you can create a new file type and
associate the perl interpreter with it as follows:</p>
<ol>
<li>
<p>Open the My Computer icon on the Desktop. The My Computer window should
appear.</p>
</li>
<li>
<p>From the View menu in the My Computer window, choose Options. The Options
dialog box appears.</p>
</li>
<li>
<p>In the Options dialog box, select the File Types tab.</p>
</li>
<li>
<p>Click the New Type button. The Add New File Type dialog box appears.</p>
</li>
<li>
<p>In the "Description of type'' box, type "Perl Script''.</p>
</li>
<li>
<p>In the "Associated extension'' box, type ".pl''.</p>
</li>
<li>
<p>Leave the Content Type (MIME) box blank.</p>
</li>
<li>
<p>Click the New button beneath the Actions list. The New Action dialog box
will appear.</p>
</li>
<li>
<p>In the Action box, type "Open'' (it's important to use this name for the
action!).</p>
</li>
<li>
<p>In the "Application used to perform action'' box, type <code>[full path
to perl]\perl.exe %1 %*</code>, where [full path to perl] is the full path
to <em>perl.exe</em> on your machine. If perl is in your path, you <em>can</em>
put just <em>perl.exe</em>, but for esoteric reasons it's better to put the
full path. Also, if the path to your interpreter includes spaces (like <em>C:\Program
Files\perl5</em>) put in the DOS path instead (<em>C:\progra~1\perl5</em>).</p>
</li>
<li>
<p>Click OK to close the New Action dialog box.</p>
</li>
<li>
<p>Click OK to close the Add New File Type dialog box.</p>
</li>
<li>
<p>Click OK to close the Options dialog box.</p>
</li>
</ol>
<p>You can test your association by double-clicking on a perl script in the
Explorer window. If <em>perl.exe</em> starts and executes the script, things are
OK.</p>
<p>On Windows NT 4.0, you can avoid all the hassle of the above and just type
the following from the command line:</p>
<pre> ASSOC .pl=PerlScript
FTYPE PerlScript=[full path to perl]\perl.exe %1 %*
</pre>
<p>For more information on these commands, type <code>HELP FTYPE</code> at the
command prompt.</p>
<p>Note that for this to work you have to have command extensions enabled.
(These are enabled by default; you'd know if you'd turned them off.)</p>