perl not working


Forum: Networking
Topic: perl not working
started by: moo_cow22000

Posted by moo_cow22000 on Aug. 17 2006,04:20
My PERL scripts which read stuff out of a text file execute in the browser but will not read the text file. It will read the text file in the command line. Can someone please help me?
Posted by clacker on Aug. 18 2006,16:58
moo_cow22000, I don't know if this helps you but here is a simple example.  First create the file below in beaver and call it /home/dsl/test.txt

Code Sample
one
two
three
four


Then create the file below in beaver and save it to /home/dsl/tut.pl

Code Sample
#!/usr/bin/perl -wT
print "Content-type: text/html\n\n";
print "Test Page start<P>\n";

$myFile = '/home/dsl/test.txt';
open(MYFILE,$myFile);
@myLines = <MYFILE>;
close(MYFILE);
print @myLines;
print "<br>Test page end\n";


Change the permission using chmod 755 /home/dsl/tut.pl

Run these commands to copy that file to /opt/monkey/cgi-bin with the correct permissions:
sudo cp /home/dsl/tut.pl /opt/monkey/cgi-bin/tut.pl
sudo chown root /opt/monkey/cgi-bin/tut.pl
sudo chgrp staff /opt/monkey/cgi-bin/tut.pl


Fire up monkey using the right click menu and choosing System->Daemons->Monkey Web Server->monkey start.  Now try to run tut.pl in the command line and as a web page and it should work:

/home/dsl/tut.pl
dillo 127.0.0.1/cgi-bin/tut.pl

Posted by moo_cow22000 on Aug. 20 2006,08:30
I just found apache in the myDSL thing and got that running and it runs my perl scripts fine. Thanks for your help anyway.
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.