CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
several questions

 

First page Previous page 1 2 Next page Last page  View All


frenchface
User

May 16, 2008, 9:31 PM

Post #1 of 28 (4710 views)
several questions Can't Post

I have tons of questions.
1)i am making a cgi script. how do i make a text box and a search button
2)the cgi script is going to search from other .pl files to find a match (they are arrays). if i have "name 500" i want someone to search for name and the website display 500. what function would be the best to use?
3)i have a script to retrieve data from a website and manipulate it into an array. would it be better for it to print the contents into a file and have the search just look in the file. or have the .pl file opened in my cgi file and have the search search the array?
4)I want my .pl script to automatically update/run at 1am everyday. what is the best way to do that?

Thanks for everyones help. I know I am a n00b but I'm tring to learn. If you have questions about what I mean just ask me please.


KevinR
Veteran


May 18, 2008, 8:10 AM

Post #2 of 28 (4634 views)
Re: [frenchface] several questions [In reply to] Can't Post

For perl based CGI scripts look into the CGI module. To run programs automatically you use cron (unix,linux) or task (windows).
-------------------------------------------------


frenchface
User

May 18, 2008, 2:19 PM

Post #3 of 28 (4620 views)
Re: [KevinR] several questions [In reply to] Can't Post

I looked into the cgi module and all the links are broken.


KevinR
Veteran


May 19, 2008, 10:21 AM

Post #4 of 28 (4597 views)
Re: [frenchface] several questions [In reply to] Can't Post

http://perldoc.perl.org/CGI.html

If you have perl installed on your local computer the documentation is also included.
-------------------------------------------------


frenchface
User

May 20, 2008, 2:22 PM

Post #5 of 28 (4562 views)
Re: [KevinR] several questions [In reply to] Can't Post

i know that this is a perl forum but i need a simple html thing i had it working but i screwed it up.

<A href='<A href='usr/lib/cgi-bin/index.pl'>click here</A>

that is what i have but it doesnt work. it gives me a 404 error. the index.pl is located in /usr/lib/cgi-bin/


KevinR
Veteran


May 20, 2008, 3:14 PM

Post #6 of 28 (4553 views)
Re: [frenchface] several questions [In reply to] Can't Post

<A href='/cgi-bin/index.pl'>click here</A>
-------------------------------------------------


frenchface
User

May 20, 2008, 5:44 PM

Post #7 of 28 (4528 views)
Re: [KevinR] several questions [In reply to] Can't Post

ok so i have another problem. I have erro 500 internal server error. and when i look in the error log it says

[Tue May 20 20:41:39 2008] [error] (2)No such file or directory: exec of '/usr/lib/cgi-bin/index.pl' failed
[Tue May 20 20:41:39 2008] [error] [client 76.123.251.81] Premature end of script headers: index.pl, referer: http://tribalwars.engr.utk.edu/

here are my two scripts

Code
click <a href="/cgi-bin/index.pl">here</a>


and


Code
 
#!/usr/local/bin/perl
#!/usr/bin/perl
use strict;
use warnings;
use CGI ':standard';

print header,
start_html('Player Point Tracker'),
h1('Kings of War'),
start_form,
'Players Name: ',
textfield('name'), br,
submit('Search!'),
end_form, p,
hr;

print 'Your name is ', param('name'), br if param 'name';
print 'You are ', param('age'), ' years old.' if param 'age';
print end_html;



KevinR
Veteran


May 21, 2008, 12:57 AM

Post #8 of 28 (4504 views)
Re: [frenchface] several questions [In reply to] Can't Post

is the index.pl script in the cgi-bin? Are you allowed to run scripts on that sever? What is the correct shebang line?


#!/usr/local/bin/perl
#!/usr/bin/perl
-------------------------------------------------


(This post was edited by KevinR on May 21, 2008, 12:58 AM)


frenchface
User

May 21, 2008, 4:47 AM

Post #9 of 28 (4498 views)
Re: [KevinR] several questions [In reply to] Can't Post

yes the index.pl is in cgi-bin, it will work becuase i had it working then i screwed something up and i think it is
#!/usr/local/bin/perl


KevinR
Veteran


May 21, 2008, 10:02 AM

Post #10 of 28 (4489 views)
Re: [frenchface] several questions [In reply to] Can't Post

try:

#!/usr/bin/perl

or ask tech support what it should be or look in a working perl script and see what it is.
-------------------------------------------------


frenchface
User

May 21, 2008, 10:05 AM

Post #11 of 28 (4488 views)
Re: [KevinR] several questions [In reply to] Can't Post

i dont think the problem is the script, because i'm getting a 404 error meaning page not found, i think if it is something with the script it would be a 500 error


KevinR
Veteran


May 21, 2008, 10:18 AM

Post #12 of 28 (4487 views)
Re: [frenchface] several questions [In reply to] Can't Post

try the full url for now:


Code
click <a href="http://www.yoursite.com/cgi-bin/index.pl">here</a>

-------------------------------------------------


frenchface
User

May 21, 2008, 1:32 PM

Post #13 of 28 (4482 views)
Re: [KevinR] several questions [In reply to] Can't Post

ok i got that working, no i have another question i have the index.pl

Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI ':standard';

print header,
start_html('Player Point Tracker'),
h1('Kings of War'),
start_form,
'Players Name: ',
textfield('name'), br,
submit('Search!'),
end_form, p,
hr;
$query->import('e.pl');
print 'Your name is ', param('name'), br if param 'name';
print end_html;


and i want it to import serval perl scripts and be able to searh the arrays of the scripts, i think i use the import() is that right and what command do i use to have it search the array? the scipts look like this


Code
my $url = 'http://en19.tribalwars.net/map/tribe.txt'; 
use LWP::Simple;

my $content = get $url;
@array=split(/,/, $content);
$n=1;
$j=4;
do
{
print "@array[$n] @array[$j]\n";
$n=$n+5;
$j=$j+5;
}
while ($n<=$#array);


In Reply To


KevinR
Veteran


May 21, 2008, 2:52 PM

Post #14 of 28 (4478 views)
Re: [frenchface] several questions [In reply to] Can't Post

is there a good reason the use a seperate perl script? Make life easier if you just combine it all in one script.
-------------------------------------------------


frenchface
User

May 21, 2008, 2:55 PM

Post #15 of 28 (4477 views)
Re: [KevinR] several questions [In reply to] Can't Post

this is for a game and what i am tring to do is to see what times a player is online and when they are not so want i want to do is have 12 scripts that update daily each one at a different hour, so 1 updates at midnight, then another one at 2. etc, do you know how to up that all in 1 script.


frenchface
User

May 21, 2008, 4:23 PM

Post #16 of 28 (4469 views)
Re: [frenchface] several questions [In reply to] Can't Post

some reason i edit my cig script it doesnt work so i change it back and i got a 500 server error is there something wrong with my script?


Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI ':standard';

print header,
start_html('Player Point Tracker'),
h1('Kings of War'),
start_form,
'Players Name: ',
textfield('name'), br,
submit('Search!'),
end_form, p,
hr;

print 'Your name is ', param('name'), br if param 'name';

print end_html;



KevinR
Veteran


May 21, 2008, 7:51 PM

Post #17 of 28 (4459 views)
Re: [frenchface] several questions [In reply to] Can't Post

looks OK, make sure you uplaod the file in ASCII (text) mode if using an FTP client to transfer from your PC to a server.
-------------------------------------------------


frenchface
User

May 21, 2008, 9:02 PM

Post #18 of 28 (4454 views)
Re: [KevinR] several questions [In reply to] Can't Post

hmmm, thats what it is on the server, i'm using putty and pico.


KevinR
Veteran


May 22, 2008, 12:24 AM

Post #19 of 28 (4449 views)
Re: [frenchface] several questions [In reply to] Can't Post

look in the sever error logs.
-------------------------------------------------


frenchface
User

May 22, 2008, 1:23 PM

Post #20 of 28 (4412 views)
Re: [KevinR] several questions [In reply to] Can't Post

i dont understand why i am getting the first one becuase the index.pl is not located there it is in var/www/cgi-bin/


[Thu May 22 15:39:19 2008] [error] (13)Permission denied: exec of '/usr/lib/cgi-bin/index.pl' failed
[Thu May 22 15:39:19 2008] [error] [client 160.36.235.98] Premature end of script headers: index.pl, referer: http://tribalwars.engr.utk.edu/


KevinR
Veteran


May 22, 2008, 2:20 PM

Post #21 of 28 (4409 views)
Re: [frenchface] several questions [In reply to] Can't Post

Does the script have execution bits turned on? chmod 755.
-------------------------------------------------


frenchface
User

May 22, 2008, 2:24 PM

Post #22 of 28 (4408 views)
Re: [KevinR] several questions [In reply to] Can't Post

yes it has the correct permissions


KevinR
Veteran


May 22, 2008, 3:31 PM

Post #23 of 28 (4404 views)
Re: [frenchface] several questions [In reply to] Can't Post

I don't know, ask your tech support guys.
-------------------------------------------------


frenchface
User

May 22, 2008, 4:02 PM

Post #24 of 28 (4398 views)
Re: [KevinR] several questions [In reply to] Can't Post

ok i figured it out, some reason it was looking in a different cgi-bin, so back to my questions

ok i got that working, no i have another question i have the index.pl
Code

#!/usr/bin/perl

use strict;
use warnings;
use CGI ':standard';

print header,
start_html('Player Point Tracker'),
h1('Kings of War'),
start_form,
'Players Name: ',
textfield('name'), br,
submit('Search!'),
end_form, p,
hr;
$query->import('e.pl');
print 'Your name is ', param('name'), br if param 'name';
print end_html;


and i want it to import serval perl scripts and be able to searh the arrays of the scripts, i think i use the import() is that right and what command do i use to have it search the array? the scipts look like this

Code

my $url = 'http://en19.tribalwars.net/map/tribe.txt';
use LWP::Simple;

my $content = get $url;
@array=split(/,/, $content);
$n=1;
$j=4;
do
{
print "@array[$n] @array[$j]\n";
$n=$n+5;
$j=$j+5;
}
while ($n<=$#array);


frenchface
User

May 22, 2008, 6:32 PM

Post #25 of 28 (4391 views)
Post deleted by frenchface [In reply to]

 

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives