Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 14th, 2007, 3:18 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,835
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Running A Perl Script Locally

I have a perl script that works fine when I access it via HTTP, but when I telnet into the server, and run the Perl script that way ("perl my_file.pl") I get an error saying it can't find some of the script's .pm files in @INC.

How can I get it to work from the shell, and not just when it's called from Apache?
Sane is offline   Reply With Quote
Old Nov 14th, 2007, 3:24 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Running A Perl Script Locally

Is everything you have locally available remotely? In the same places?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 15th, 2007, 10:30 AM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,835
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Running A Perl Script Locally

Hmm, either you're ahead of me already, or I messed up my explanation.

When I say "locally" I mean remotely with respect to my computer, but locally with respect to the server. So all of the resources should be the same, since it's being run in the same location. Is that correct?
Sane is offline   Reply With Quote
Old Nov 15th, 2007, 10:38 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Running A Perl Script Locally

Hmmmm. I don't know. Let me just ask a question: is it possible that when accessed via http that the paths involved are relative to the document root, whereas they're different via telenet?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 15th, 2007, 11:34 AM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,835
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Running A Perl Script Locally

Sounds entirely possible. When I ran it in telnet, the working directory was the same as the directory the script was located within. Maybe Apache makes the working directory the Perl folder or something.

I will write a script to output where it was called from to find out.

Edit : Well, that's interesting. /www/user/cgi-bin

It says the (absolute) working directory is one that doesn't even exist. Where the hank is /www/ on my machine?

Last edited by Sane; Nov 15th, 2007 at 11:45 AM.
Sane is offline   Reply With Quote
Old Nov 15th, 2007, 12:33 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Running A Perl Script Locally

Mine's Apache2/htdocs/www.

It was a lucky shot in the dark. I get bit by it all the time writing PHP. Some paths need to be URLs, which relate to home (www), others need to deal with the filesystem path.

EDIT. If your server is a paid host, check the environment variables for something like DOCUMENT_ROOT. Mine is, for example, /mnt/w0302/d08/s33/b0246102/www. The part before www is the environment variable, HOMEDIR. In my case, the filesystem path to cgi-bin is under HOMEDIR, but Apache/my host map it, URL-wise, as if it's a subdirectory of www.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers

Last edited by DaWei; Nov 15th, 2007 at 12:47 PM.
DaWei is offline   Reply With Quote
Old Nov 15th, 2007, 12:51 PM   #7
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,835
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Running A Perl Script Locally

Hmm, I have a guess on what the problem is.

I printed out @INC (the equivilent of PATH for Perl), when it was run in the terminal, and it's identical to the @INC from when it's called by Apache.

Although the PATH is the same, it's missing the one pm file "DBD/mysql.pm". This is the only pm file it's missing out of all the files it includes. And I can't find that anywhere on the computer.

It didn't occur to me until now that the "server" I'm accessing might not be a server at all. I believe it's a document repository that's pointed to by Apache to serve the files.

Okay, I just checked. There's two separate IPs. One IP for the website, and one IP for the "server".

Since "DBD/mysql.pm" is not specified in @INC, but Apache can still find it, it's probably on the other computer.

There's not going to be a way around this is there? How can I confirm that "DBD/mysql.pm" is indeed not on the server, but on the Apache server, before I report this to my boss? I don't want to tell him some made-up problem without any proof.
Sane is offline   Reply With Quote
Old Nov 15th, 2007, 1:04 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Running A Perl Script Locally

Sorry, I have no idea. You picked my brain clean on the subject.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 17th, 2007, 6:22 AM   #9
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
Re: Running A Perl Script Locally

gee, this is fun...
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Nov 17th, 2007, 6:23 AM   #10
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
Re: Running A Perl Script Locally

Have you considered the file privileges?

viele Grüße
Steven
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a Mac-Written Script on a Linux Machine Sane Perl 2 Nov 1st, 2007 8:46 PM
Problem with Perl script eclipsed4utoo Perl 1 Dec 2nd, 2005 1:33 PM
A simple perl script satimis Perl 3 Aug 15th, 2005 9:31 AM
HELP!!! Perl script to display drop down menu on webpage domquem Perl 8 Jun 2nd, 2005 9:48 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:52 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC