Perl is a very powerful scripting language and is fully supported by The Uniform Server Zero. You can install one of two distributions; either Portable Strawberry Perl via a Uniform Server Zero plugin or Active Perl. The ActivePerl Community License precludes distribution with The Uniform Server Zero; you will need to download this yourself. Remainder of this page covers UniController's Perl control menu. OverviewInstall Perl as explained on this page: Installing Perl. The Uniform Server automatically detects the presence of Perl and enables its menu in UniController. If Perl is not installed, the Perl menu is greyed out. Place your Perl scripts in folder UniServerZ\cgi-bin and any sub-folders as appropriate. Each script requires a Shebang. This must be an absolute path to the Perl executable. For example: #!C:/UniServerZ/core/perl/bin/perl.exeor (Unix format) #!/usr/bin/perl Note: The #! means "use the following command/interpreter to run this script". Generally, the command/interpreter is the absolute path to an executable. Next section covers the Shebang in more detail. ShebangThe Shebang format you use is dependent on a number of factors, such as on how the Apache server is run (either as a standard program or as a service) and the operating system. Apache – Running as standard programWhen Apache is started from UniController, it is run as a standard program and is fully portable. #!perl Moving UniServer Zero to another location automatically updates the path environment variable. Tip: When writing Perl scripts for Windows, always use #!perl for the Shebang. Important: When you place a third party Perl script in cgi-bin, you must always run Force Windows Shebang using UniController; this converts the Unix Shebang to the Windows format. Alternatively, you can manually edit each file and replace the Unix Shebang #!/usr/bin/perl with the Windows Shebang #!perl Apache – Running as serviceWhen Apache is started from UniService, it is run as a service and is no-longer portable. Running as a service requires the Shebang to be an absolute path. For example: #!C:/UniServerZ/core/perl/bin/perl.exe You need to edit each file and replace the Shebang with #!C:/UniServerZ/core/perl/bin/perl.exe. If you installed Uniform Server in a different location, adjust the path as appropriate. Although inconvenient, it is a relatively easy task to search all files in cgi-bin and replace the Shebang. Note 1: The above runs on any Windows OS. Shebang HelpPerl > Shebang Help The Perl Shebang Help menu displays the following: Shebang Help:
Force Windows ShebangAfter installing third-party scripts to the cgi-bin folder, force a Windows Shebang update by running Force Windows Shebang from the Perl drop-down menu. Perl > Force Windows Shebang This updates all files with the following file extensions in folder cgi-bin and any sub-folders:
Replaces the current Shebang with #!perl Force Unix ShebangPerl scripts developed on Windows will not run on a Unix machine. They require conversion to Unix format. Force a format update by running Force Unix Shebang from the Perl drop-down menu. Perl > Force Unix Shebang This updates all files with the following file extensions in folder cgi-bin and any sub-folders:
Replaces the current Shebang with #!/usr/bin/perl View test.plView test.pl runs test script: UniServerZ\cgi-bin\test.pl Perl > View test.pl test.pl #!perl print <<END_of_HTML; Content-type: text/html <HTML> <HEAD> <TITLE>Perl Test Page</TITLE> </HEAD> <BODY> <H1>Perl test page</H1> <P>Basic Perl test pages.</P> <ul> <li><a href="http://localhost/cgi-bin/test_1.pl/" target="_blank">test_1.pl - Display Perl environment</a></i> <li><a href="http://localhost/cgi-bin/test_2.pl/" target="_blank">test_2.pl - Basic "Hello world"</a></i> </ul> <p>The above test pages are located in folder <b>UniServerZ\\cgi-bin</b>. After testing, these pages can be deleted:<br /> Main Test page test.pl, pages test_1.pl and test_2.pl</p> </BODY> </HTML> END_of_HTML Where to go nextInstalling Perl - Covers installing ActivePerl and Strawberry Perl --oOo--
|