patricia_e has asked for the wisdom of the Perl Monks concerning the following question:
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.phpThe 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP::UserAgent with development website
by astroboy (Chaplain) on Sep 17, 2004 at 23:33 UTC | |
by jdalbec (Deacon) on Sep 18, 2004 at 00:27 UTC | |
|
Re: LWP::UserAgent with development website
by TheHobbit (Pilgrim) on Sep 18, 2004 at 12:32 UTC |