Jump to content


Photo

Different shebang for server running as program and server running as a service?

Perl Shebang Server runnig as program Server running as service

  • Please log in to reply
2 replies to this topic

#1 sacoman

sacoman

    Newbie

  • Member
  • Pip
  • 2 posts
  • Main OS: Windows 7

Posted 15 December 2014 - 10:31 PM

Platform: Windows, UniserverZ 11, ActivePerl.
I use several directories for cgi. In each of them there is a .htaccess file with two lines: Options +ExecCGI and AddHandler cgi-script .pl .cgi .exe.
The Perl programs start with #!perl.
Starting the server with UniController.exe, Perl programs run properly.
Starting the server as a service using UniService.exe, I get error 500.
For error 500, the Apache log reports /dir1/dir2/.../someprogram.pl was not found.
Running as service I can solve the problem using absolute address for perl.exe, for example, #!C:/UniServerZ/core/perl/bin/perl.exe.
I'm thinking of the possibilities:
[1] This is a bug of the service or
[2] That's right, but I have not found documentation about or
[3] I'm missing something.
Thank you for the answers.


#2 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 17 December 2014 - 01:44 PM

Your solution "I can solve the problem using absolute" is correct! It is a requirement for Window XP.

However I noticed you are using Windows 7 there is a more elegant solution that allows you to use the Unix shebang "#!/usr/bin/perl" when running the servers either as a standard program or service.
 
Create two new files (link_create.bat and link_delete.bat)  in folder UniServerZ with the following content:

link_create.bat

rem working directory current folder
pushd %~dp0

rem save us path
set us_path=%cd%

rem change to top level
cd \

rem create link
mklink /D usr %us_path%\core\perl

rem restore original
popd
pause

link_delete.bat

rem working directory current folder
pushd %~dp0

rem save us path
set us_path=%cd%

rem change to top level
cd \

rem delete link
rd usr

rem restore original
popd

Run link_create.bat (right click on file link_create.bat and run as administrator) allow program to make changes. This creates a symbolic link to the Perl executable.

Start UniController. From the Perl tab run "Force Unix Shebang" you only need to perform this once.
From UniController start Apache and check your Perl scripts run.
Close Apache and UniController.

Start UniService install and run Apache. Again check your Perl scripts run.

Note: To remove the link double click on file link_delete.bat

All the best
Ric



#3 sacoman

sacoman

    Newbie

  • Member
  • Pip
  • 2 posts
  • Main OS: Windows 7

Posted 17 December 2014 - 05:40 PM

Ric.
Thank you very much for the answer.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users