Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm tring to upload a script to a Windows server, having only ever used unix before. the following script works on unix but I'm now getting a software enrror - seemingly because it is unable to configure CGI. The code is:
#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI ':standard'; use LWP::Simple; my ( $target, $key, $value, $page, $content ); my %list = ( "http://www.mysite.com/away/index.html" => "D:\inetpub\wwwroot\017172\1sdhpnc1\trial.h +tml" ); while ( ($key, $value) = each (%list) ) { $target = $key; $page = $value; $content = get($target); #Actually send the request to the webse +rver die "Couldn't get $target!" unless defined $content; open FH, "> $page" or die $!; flock (FH, 2) or die "lock: $!"; print FH "$content"; } print "Content-type: text/html\n\n"; print "$content";
and the error is:
Can't continue after import errors at D:\inetpub\wwwroot\017172\1sdhpn +c1\cgi-bin\cm_update.pl line 3 BEGIN failed--compilation aborted at D +:\inetpub\wwwroot\017172\1sdhpnc1\cgi-bin\cm_update.pl line 3.
Any help in getting this going, much appreciated

Replies are listed 'Best First'.
Re: problems using Windows server
by FitTrend (Pilgrim) on Feb 11, 2005 at 15:44 UTC

    Since you are double quoting the windows path, this section of code should be written like:

    my %list = ("http://www.mysite.com/away/index.html" => "D:\\inetpub\\wwwroot\\017172\\1sdhpnc1\\trial.h +tml" );

    (Escape your backslashes)

    Sincerely,

      Thanks, that looks sensible and I have incorporated it. However the problem seems to be in the use commands.

      I found this 'hello world' script on the server and added the use cgi::carp line which is commented out. It runs like this, but with the comment hash taken out I get the same error message. I hope this helps to ring a bell for someone...

      #use CGI::Carp qw(fatalsToBrowser warningsToBrowser); print "Content-Type: text/html\n\n"; print "<HTML>\n"; print "<HEAD>\n"; print "<TITLE>Hello World</TITLE>\n"; print "</HEAD>\n"; print "<BODY>\n"; print "<H4>Hello World</H4>\n"; print "<P>\n"; print "Your IP Address is $ENV{REMOTE_ADDR}.\n"; print "<P>"; print "<H5>Have a nice day</H5>\n"; print "</BODY>\n"; print "</HTML>\n";
        Try just using CGI alone;

        Then just CGI::Carp()
      Forward slashes work fine for most calls on Windows, so you can keep your Unix code there.

      If you want to write really portable code, you can use File::Spec->catfile() to join path elements.

Re: problems using Windows server
by dragonchild (Archbishop) on Feb 11, 2005 at 14:54 UTC
    Did you use the ASCII mode to FTP the file up?

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      I checked that it was so by reloading it - still get the same error... :(
Re: problems using Windows server
by RazorbladeBidet (Friar) on Feb 11, 2005 at 15:20 UTC
    Is that the error message at the browser?

    If so, have you tried running at the command line?

    What Win32 perl are you using?
      Yes it's a browser error. I don't have commandline access :( using Windows_NT cheers
Re: problems using Windows server
by holli (Abbot) on Feb 11, 2005 at 17:37 UTC
    - seemingly because it is unable to configure CGI.
    So, as it seems, you basically anwered the question yourself. Your problem is the webserver. Can you tell us what webserver it is?


    holli, /regexed monk/
Re: problems using Windows server
by monkey_boy (Priest) on Feb 11, 2005 at 14:59 UTC
    Should this:
    #!/usr/bin/perl -w
    not be a windows path?


    Im so sick of my Signature...
      My understanding is that Windows ignores the shebang line altogether...
        but Perl doesn't ignore it, so it's best to leave it there
        My understanding is that Windows ignores the shebang line altogether...
        But then my (admittedly limited) understanding is that at least some webservers do emulate shebang line emulation even under Windows.