Running a perl Script

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Running a perl Script

Post by evilmonkey »

Hello. Before I start with my problem, let me point out that I have never used perl before. That's right never even ran a perl script. I'm a PHP man, but I have come to a point where I need to use Perl.

So I have a perl script, and I have no idea what to do with it. I uploaded to a directory first, ran it, got a 500 error. Uploaded it to the cgi-bin directory, 500 error. Did some reaserch ( ;) ) and chmodded it to 755. Got this error:
You must run this script from the command line.
At this point I thought that I was screwed because i don't have command-line access to the server (other than a cron job). I am on a shared hosting platform. But then I dug into the code and found this:

Code: Select all

############################################################              
# Some people try to run this as a CGI. That's wrong!
############################################################              
if ( defined( $ENV{'PATH_INFO'} )
    || defined( $ENV{'QUERY_STRING'} )
    || defined( $ENV{'REQUEST_METHOD'} ) ) {
    print "Content-Type: text/html\n\n";
    print "You must run this script from the command line.";
    exit;
    }
Well if running it as CGI is wrong, what do I do? If I need to set up a cron job, someone please tell me exactly what to put in.

If anyone is wondering, this is the SquirrelMail set-up script. Yes, I know there is a config.php file. Yes, I have edited it to fit my needs. But I still want to run this script. But how?

Thanks.

Cheers!
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

Post by jmarcv »

look at exec()
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

What's exec()? And of what language?
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

Post by jmarcv »

User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

I don't rally understand this command. I tried:

Code: Select all

<?php
exec ("conf.pl");
?>
but that did nothing. Little more help please.
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

Post by jmarcv »

Did you go to the link?
If you need to get data back, that is more complicated.
Also, if php does not have permission to execute the program, nothing will happen. It can be a tricky command to use, and not all hosting companies support it.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

:( i guess I need shell access to get this thing going :(
Post Reply