Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: perl not working, Perl will not read text files< Next Oldest | Next Newest >
moo_cow22000 Offline





Group: Members
Posts: 4
Joined: Aug. 2006
Posted: Aug. 17 2006,04:20 QUOTE

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?
Back to top
Profile PM 
clacker Offline





Group: Members
Posts: 570
Joined: June 2004
Posted: Aug. 18 2006,16:58 QUOTE

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
Back to top
Profile PM 
moo_cow22000 Offline





Group: Members
Posts: 4
Joined: Aug. 2006
Posted: Aug. 20 2006,08:30 QUOTE

I just found apache in the myDSL thing and got that running and it runs my perl scripts fine. Thanks for your help anyway.
Back to top
Profile PM 
2 replies since Aug. 17 2006,04:20 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: perl not working

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code