Hi,

I'm extremely new to perl. so I apologize in advance for the newbie question...

Our sysadmin recently ported our website onto a new unix box. I am updating scripts on this new development site.

The script I'm currently updating is one that asks users for a number which corresponds to a job number. This entered job number has a corresponding file in a certain directory on the new server. Each file's name is like this:

70330.php
70340.php
etc....

The html pages asks the user to input what job number they are searching for and then looks to see if that a file exists that corresponds to that job number. If it does, it displays it. If not, it returns an error message.

The oldest version of this is:

#!/usr/local/bin/perl unshift(INC, "/usr/local/lib"); require("perl-forms-lib"); &form'Parse(); print "Content-type: text/html\n\n"; if ($in{'jobcode'}) { &displayByJobNumber($in{'jobnumber'}); } else { &search($in{'search'}); } sub displayByJobNumber { ($jobNumber) = @_; $file = $jobNumber . ".php"; if (-f $file) { $fileContents = `cat $file`; print $fileContents; } else { print <<EOM; There is no job with that job number. Pick another. EOM } } # end sub displayByJobNumber

**** this doesn't work on my new server. I suspected the cat unix command for some reason. I got on the Chatterbox feature of perl monks where the members steered me to LWP::UserAgent.

After that, I changed my code to read like this:

#!/usr/local/bin/perl unshift(@INC, "/usr/local/lib"); require LWP::UserAgent; use CGI qw(param); require("perl-forms-lib"); &form'Parse(); print "Content-type: text/html\n\n"; if ($in{'jobcode'}) { &displayByJobNumber($in{'jobnumber'}); } else { &search($in{'search'}); } sub displayByJobNumber { ($jobNumber) = @_; $file = "../../06_jcl/jobdesc/" . $jobNumber . ".php"; my $ua = LWP::UserAgent->new; $modfile = $file."?var=".$jobNumber; my $response = $ua->get('<url of directory location on my developm +ent server here>'); if (-f $file) { print $response->content; } else { print <<EOM; There is no job with that job number. Pick another. EOM } } # end sub displayByJobNumber

****** This didn't work.

It DID work when I put the url of the old server into the line:

my $response = $ua->get('<url of directory location on old server h +ere>');

Also, when I put the url of my development box back in there without the last few nested directories (just put in the bare url of the general site), it displayed a web page that might be on the server BUT was definitely not one of my pages. It looked like it was a page from a different website that has some space on the server.

Do you have any idea why this might be?

Could it have to do with the fact that our url is somewhat temporary on this development site? It will eventually be given the official url once we go live.

Thanks in advance for any insights into this problem.

janitored by ybiC: Balanced <readmore> tags around longish codeblock, as per Monastery convention


In reply to LWP::UserAgent with development website by patricia_e

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.