in reply to What is the best practice to migrate scripts from test to production

I have a similar situation where I want to run the same cgi scripts locally and on the webhoster. This is what I've come up with.

Perhaps something similar would be of use?

#!/usr/bin/perl use strict; use warnings; my ($local, $root, $domain); BEGIN { $local++ if $ENV{HTTP_HOST} =~ m|localhost|; if ($local){ $root = q{/www/local}; } else{ $root = q{/path/on/webhoster/htdocs}; } $domain = q{sw/admin}; } use lib ( qq{$root/lib}, qq{$root/$domain/lib}, ); use Article; # rest of script...
update: changed the paths
  • Comment on Re: What is the best practice to migrate scripts from test to production
  • Download Code

Replies are listed 'Best First'.
Re^2: What is the best practice to migrate scripts from test to production
by Anonymous Monk on Jun 27, 2007 at 18:21 UTC

    Thanks for the response

    Unfortunately, I can't use your approach as my "test" and "production" scripts are in the same server, but under different directories. Hence, "HTTP_HOST" returns the same value for both "test" and "production".

    But, I noticed that env variables, "REQUEST_URI" and "SCRIPT_FILENAME", has the "test" or "prod" string string attached to them (i.e, if the script name is test.cgi, the REQUEST_URI string has a value of "/testenvir/test.cgi" in 'test' environment and "/prodenvir/test.cgi" in 'prod' environment, respectively).

    I am going to check if I can use your logic with the above ENV variable(s).

    Is that a good approach?

    Thanks,Vgn

      Rather than having an extra conditional in your code, you might read the path from the environment.

      ...roboticus