Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Resource Not Found error

by StorminN61 (Initiate)
on May 05, 2025 at 17:48 UTC ( [id://11164951]=perlquestion: print w/replies, xml ) Need Help??

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

Recently copied a Perl script to a new server since old one is no longer in compliance. When I run the script on the old server, it creates a text file, aka trigger file, which is used by IBM Workload Scheduler to start processing a particular job. Depending on the trigger file, IWS determines which job should run. I copied the directory structure on the new server, made the IIS entries on the new server match what is on the old server, but when I try to create the triggers, I get the 404 Resource not found error, with no further information as to what resource it is specifically missing.

#!/usr/bin/perl -w use CGI; print "Content-type: text/html\n\n"; print "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"tex +t/html; charset=iso-8859-1\" />\n"; print "<link rel=\"stylesheet\" href=\"http://pctldocs/doc_style.css\" + type=\"text/css\" />\n"; print "<title>Trigger Result</title>\n</head>\n"; print "<body>\n"; print "Result:<br />"; my @query = split(/=/, $ENV{'QUERY_STRING'}); my $term = $query[$#query]; my $file = 'd:\\apps\\AETrigger\\' . $term . '.txt'; if (open (FH, '>', $file)) { print "Trigger for $term ($query[0]) has been created."; } else { print "Error creating trigger; please contact support."; } print "</body>\n</html>";

Replies are listed 'Best First'.
Re: Resource Not Found error
by GrandFather (Saint) on May 05, 2025 at 22:07 UTC

    First off I'd restructure that somewhat to separate the business logic from generating the HTML. That makes it possible to see the actual code. Along the way I'd switch to using a lexical file handle.

    But most importantly I'd trap runtime error and report any error returned by open if it fails. Putting that all together along with modern strictures you get:

    use warnings; use strict; use CGI; my $result; eval { my @query = split(/=/, $ENV{'QUERY_STRING'}); my $term = $query[$#query]; my $file = 'd:\\apps\\AETrigger\\' . $term . '.txt'; $result = open (my $fh, '>', $file) ? "Trigger for $term ($query[0]) has been created." : "Error '$!' creating trigger; please contact support."; return 1; } or do { $result = "Error: $@"; }; print <<HTML; Content-type: text/html <html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; ch +arset=iso-8859-1" /> <link rel="stylesheet" href="http://pctldocs/doc_style.css" type="text +/css" /> <title>Trigger Result</title>\n</head> <body> Result:<br /> $result </body>\n</html> HTML

    If that doesn't get you a page reporting the error then more likely you have a configuration error somewhere. Have you tried a simple "Hello World" program?

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      I have been able to run other Perl scripts on that server, so I don't think it is a configuration error with Perl. I tried your suggestion, but still get the "404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable." error.

        A 404 error is from the server so either the URL is broken or there is a configuration error somewhere. Nothing you can do in the code can fix the issue.

        Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11164951]
Approved by davies
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2025-05-25 02:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.