Om du börjar med att beskriva ditt problem så blir det nog lättare att hjälpa dig. :)
------------------
Robban < robban@lipogram.com >
Perl & Rubyur Perl, Python, Ruby och övrig CGI
20 svar · 564 visningar · startad av Tengblad
Någon som har lust att hjälpa mig med ett script. Det är ett färdigt script som jag har ändrat lite i. Jag är typ jätte nybörjare inom cgi/perl.
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Om du börjar med att beskriva ditt problem så blir det nog lättare att hjälpa dig. :)
------------------
Robban < robban@lipogram.com >
ahh sorry glömde de :r
Jo det är så här att jag får inte scriptet att fungera och jag vet inte riktigt vad som felar!?
När man testar om det funkar att klicka på "Uppdatera" i htmldokumentet(udater.html) på servern så får jag bara "Internal Server Error"?
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Första raden i Perl-filen ska vara #!/usr/bin/perl
Har du laddat upp update.pl som ASCII och inte i binärt format? Kolla att du har satt rättigheterna på rätt sätt (CHMOD 755).
------------------
Gislaved.net
"Tänk på vad du säger så att du inte säger vad du tänker."
Döp scriptet till testmy.pl och ladda upp och sätt rättigheterna (CHMOD 755). Nu kan du, med hjälp av detta script, leta upp felet! ;)
#!/usr/bin/perl
#
# TestMy.CGI version 0.2 by Craig Richards
#
# You may need to change the server's path to Perl (above)
# A good alternate is !/usr/local/perl
# Use whatever is at the top of any existing (working) scripts
# on your server.
#
# Do not change the name of this script as its performance will
# be adversely affected. However, you may change the extension
# to ".pl" if ".cgi" is not supported by your server.
#
# To include "warnings" in your reports, simply add -w
# after the path to perl at the top of any scripts you're
# testing, i.e. #!/usr/local/bin/perl -w
#
# TestMy.CGI is a Perl 5 script that tests the syntax of your
# scripts and presents a report of any errors directly to
# your browser. You can easily navigate your entire site's
# directories with its simple point-and-click directory and
# file table.
#
# Simply upload this file (as a text file) to any directory
# on your domain or in the root. Your server administrator
# might restrict executables to a cgi or cgi-bin directory,
# so that's where you'd want to put this file.
#
# On Unix/Linux and other servers, set the file permission
# to 755 (world executable or rwxr-xr-x).
#
# That's it! Now open your browser and type:
# [url="http://www.mydomainhere.com/path/testmy.cgi"]http://www.mydomainhere.com/path/testmy.cgi[/url]
# ^ ^ your domain and path go here)
# then follow the simple online prompts.
#
#
# We encourage your feedback and suggestions; however,
# TestMy.CGI is distributed as "freeware" (no license fee is
# collected) so user support is not available. User agrees to
# run this application at his/her own risk, assumes all
# liability, and no warranty as to the suitability or
# performance of TestMy.CGI for your specific purpose is
# stated nor implied. If dissatisfied with TestMy.CGI,
# discontinue use.
#
# TestMy.CGI may be freely distributed via the Internet or
# included on CD-ROM as long as the original source code,
# comments and credits remain intact. TestMy.CGI is free and
# may not be individually sold though it may be bundled with
# other software whether that distribution contains other
# software that is free, shareware, demo or sold. In essence,
# no one should materially profit from distribution of this
# script.
#
# You are urged not to link to this script from any public
# pages on your site as TestMy.CGI displays all the paths and
# documents - even hidden ones - on your site. Public access to
# TestMy.CGI may compromise the security of your site
# and/or server.
#
# Application and interface is (c)Copyright 2000.
# All rights reserved worldwide.
#
# If you like this handy debugging tool, let me know. In my spare
# time, I will continue to add new features.
# go to [url="http://www.CraigRichards.com/software/"]http://www.CraigRichards.com/software/[/url] for upgrade info
# as it becomes available.
#
# Feel free to email me at "CGI@CraigRichards.com" with your
# comments and/or suggestions.
#
##########
# VARIABLES DEFINED
&inParse;
$RootDir = "$ENV{'DOCUMENT_ROOT'}";
$fnt = "<FONT SIZE=2 FACE=\"arial,helvetica,sans-serif\">";
$fnt1 = "<FONT SIZE=1 FACE=\"arial,helvetica,sans-serif\">";
$version = "v 0.2";
$c1 = "8C4D99"; # heads & borders
$c1 = "7F007F"; # heads & borders
$c2 = "000000"; # subtle color
$c3 = "EDEDED"; # DIR/FILE table background color
$c4 = "EDEDED"; # instruct/results background color
$c5 = "000000"; # overall interface background color
##########
# OPTIONAL ACCESS-RESTRICTION SECURITY FEATURE
$secure = 0; # Set this value to 1 to enable IP address security.
if ($secure eq 1) {&security;}
sub security {
# IF YOU ADMINISTRATE YOUR SITE FROM A DESKTOP WITH A
# STATIC IP ADDRESS, INPUT THAT ADDRESS HERE:
# note: for multiple administrators, just duplicate
# the line above to add more static IP addresses.
$ipaddress .= "000.000.000.000";
if (($secure eq 1) && ($ENV{REMOTE_ADDR} =~ "$ipaddress")) {
print "Location:http://www.CraigRichards.com/restricted.html\n\n";
exit;
}
}
##########
# CONDITIONAL VARIABLES DEFINED
$title = "Script Testing";
if (!$t{'run'}) {
$path = "$ENV{'SCRIPT_NAME'}";
$t{'testmycgi'} = "$ENV{'SCRIPT_NAME'}";
$path =~ s/testmy\.cgi//; $path =~ s/testmy\.pl//;
$title = "How To Use TestMy.CGI";
&instblock;
push(@error,"$instructions");
}
else {
$path = "$t{'path'}";
if ($path !~ /\/$/) {
$path =~ s/(.*)/$1\//;}
$path =~ s/\/\//\//;
if (!$t{'test'}) {
$title = "How To Use TestMy.CGI";
&instblock;
push(@error,"$instructions");
}
else {
if (not(-e "$RootDir$path$t{'test'}")) {
push(@error,"<TR><TD>$fnt <FONT COLOR=FF0000>Sorry, could not find <B>$t{'test'}</B>.</FONT><BR>Check the file name and try again.</TD></TR>");
$title = "Error - File Not Found";
}
else {
&runtest;
}
}
}
&result;
##########
# TEST THE SYNTAX
sub runtest {
@all = `($RootDir$path$t{'test'} | 's/^/stdout:/') 2>&1`;
for (@all) {push @{s/stdout://?\@outlines: \@errlines},$_}
if (@errlines) {
if (($ENV{SERVER_SOFTWARE} =~ /(unix|linux)/i) && (not(-x "$RootDir$path$t{'test'}"))) {
push(@error,"<TR><TD COLSPAN=2>$fnt <FONT COLOR=FF0000>Sorry, <B>$t{'test'}</B> does not appear to be executable.</FONT><BR>\nSet file permissions to 755 or 775 and test again.</TD></TR>");
}
foreach $errline(@errlines) {$qty++;
$errline =~ s/ (at|of) //;
$errline =~ s/$RootDir$path$t{'test'}//;
$errline =~ s/line /line /;
$errline =~ s/</</;
$errline =~ s/>/>/;
$errline =~ s/\////;
$error = "<TR VALIGN=TOP><TD ALIGN=RIGHT>$fnt1 $qty</TD><TD>$fnt $errline</TD></TR>\n"; push(@error,$error);
}
}
else {
push(@error,"<TR><TD>$fnt No errors were found when testing <B>$t{'test'}</B></TD></TR>");
$title = "Congratulations!";
}
}
##########
# PRINT TEST RESULT
sub result {
&viewDir;
&form;
print "Content-type: text/html\n\n";
print <<"Error";
<HTML><HEAD><TITLE>TestMy.CGI | $title</TITLE>
<BODY BGCOLOR=$c4 MARGINWIDTH=12 MARGINHEIGHT=6 LEFTMARGIN=12 RIGHTMARGIN=12 TOPMARGIN=6 BOTTOMMARGIN=6 TEXT=000000 LINK=$c2 ALINK=FF0000 VLINK=$c1 onLoad="document.TestMyCGI.test.focus();"><BASEFONT SIZE=2>$fnt1
$head
<CENTER><TABLE BGCOLOR=$c5 CELLPADDING=9 CELLSPACING=0 BORDER=0><TR ALIGN=CENTER VALIGN=TOP><TD><TABLE BGCOLOR=$c1 CELLPADDING=1 CELLSPACING=0 BORDER=0><TR VALIGN=MIDDLE><TD COLSPAN=3><FONT COLOR=FFFFFF>$fnt1
< <A HREF=\"$t{'testmycgi'}?testmycgi=$t{'testmycgi'}&path=$returnpath&run=yes\" onMouseOver="window.status='return to the parent directory'; return true;" onMouseOut="window.status=''; return true;" TITLE="click here to navigate to the parent path"><FONT COLOR=FFFFFF>..$returnpath</FONT></A> (return to parent)</TD></TR>
<TR ALIGN=CENTER><TD BGCOLOR=$c3 COLSPAN=3>$fnt1 current path:<BR>
<FONT SIZE=3 FACE="helvetica,arial,sans-serif"><B>$path</B></FONT></TD></TR>
<TR BGCOLOR=$c5 ALIGN=CENTER VALIGN=TOP><TD BGCOLOR=$c5><TABLE BGCOLOR=$c3 CELLPADDING=5 CELLSPACING=0 BORDER=0>
<TR VALIGN=TOP><TD NOWRAP>$fnt<FONT COLOR=$c1><B>DIR</B></FONT><BR>\n$fnt1 $directorydata</TD></TR></TABLE></TD>\n<TD BGCOLOR=$c5 WIDTH=1><IMG SRC="http://www.CraigRichards.com/images/clear.gif" WIDTH=1 HEIGHT=1></TD><TD BGCOLOR=$c5><TABLE BGCOLOR=$c3 CELLPADDING=5 CELLSPACING=0 BORDER=0><TR VALIGN=TOP><TD NOWRAP>
$fnt<FONT COLOR=$c1><B>FILE</B></FONT><BR>$fnt1
$filedata</TD></TR></TABLE></TD></TR></TABLE>
</TD><TD BGCOLOR=$c5>$fnt
<FONT COLOR=FFFFFF>
$form<P>
<TABLE BGCOLOR=$c1 CELLPADDING=1 CELLSPACING=0 BORDER=0><TR ALIGN=CENTER VALIGN=MIDDLE><TD><FONT SIZE=3 COLOR=FFFFFF FACE="helvetica,arial,sans-serif"><B>$title</B><BR>
<TABLE BGCOLOR=$c4 CELLPADDING=5 CELLSPACING=0 BORDER=0>
@error
</TABLE></TD></TR><TR ALIGN=RIGHT><TD BGCOLOR=$c5 NOWRAP><FONT SIZE=1 COLOR=FFFFFF FACE="arial,helvetica,sans-serif">by <A HREF="http://www.CraigRichards.com/" onMouseOver="window.status='click here to go to Craig Richards Design now'; return true;" onMouseOut="window.status=''; return true;" TITLE="click here to go to Craig Richards Design now"><FONT COLOR=FFFFFF>Craig Richards Design</FONT></A></TD></TR></TABLE>
</TD></TR></TABLE></CENTER><P>
$foot
Error
}
sub form {
$form = <<"Form";
$fnt1<FORM ACTION="$t{'testmycgi'}" NAME=TestMyCGI METHOD=POST>
<INPUT TYPE=HIDDEN NAME="testmycgi" VALUE="$t{'testmycgi'}">
path <INPUT TYPE=TEXT NAME="path" SIZE=15 MAXLENGTH=100 VALUE="$path" TITLE="type the path to the script you want to test">
script <INPUT TYPE=TEXT NAME="test" SIZE=15 MAXLENGTH=200 VALUE="$t{'test'}" TITLE="type the name of the script you want to test"> <INPUT TYPE=SUBMIT NAME="run" VALUE="EXECUTE" TITLE="click here to refresh the directory table, to change the path or to test a script"></FORM></FONT>
Form
$head = <<"Head";
<TABLE CELLPADDING=9 CELLSPACING=0 BORDER=0><TR VALIGN=TOP><TD WIDTH=100% ALIGN=CENTER NOWRAP>$fnt1<A HREF="http://www.CraigRichards.com/" onMouseOver="window.status='click here to go to Craig Richards Design now'; return true;" onMouseOut="window.status=''; return true;" TITLE="click here to go to Craig Richards Design"><IMG SRC="http://www.CraigRichards.com/images/testmycgi96x21.gif" WIDTH=96 HEIGHT=21 ALIGN=MIDDLE BORDER=0 ALT="TestMy.CGI"></A> $version</TD><TD ALIGN=RIGHT NOWRAP>$fnt<FONT SIZE=1 COLOR=909090>TestMy.CGI $version is freeware and may be distributed only in its original form.<BR>
© Copyright 2000 Craig Richards Design. All rights reserved worldwide.
</FONT></TD></TR></TABLE>
$fnt
Head
$foot = "</FONT></BODY></HTML>\n";
}
##########
# SUB REPORT FILES IN DIRECTORY
sub viewDir {
opendir (DIR, "$RootDir$path");
@allfiles = grep(!/^\.\.?$/, readdir(DIR));
foreach $file(@allfiles) {
if ((-d "$file") || ($file !~ /\./)) {push (@dirs," <A HREF=\"$t{'testmycgi'}"."?testmycgi=$t{'testmycgi'}&path=$path$file/&run=yes\" onMouseOver=\"window.status='click here to open the \\'$file\\' directory now'; return true;\" onMouseOut=\"window.status=''; return true;\" TITLE=\"click here to open the \'$file\' directory\">$file</A><BR>\n");} # it's a directory
elsif (-x "$file") {push (@files," <A HREF=\"$t{'testmycgi'}"."?testmycgi=$t{'testmycgi'}&path=$path&test=$file&run=yes\" onMouseOver=\"window.status='click here to test \\'$file\\' now'; return true;\" onMouseOut=\"window.status=''; return true;\" TITLE=\"click here to test \'$file\'\">$file</A><BR>\n");} # it's executable
elsif (-f "$file") {push (@files," <! A HREF=\"$t{'testmycgi'}"."?testmycgi=$t{'testmycgi'}&path=$path&test=$file&run=yes\" onMouseOver=\"window.status='click here to test \\'$file\\' now'; return true;\" onMouseOut=\"window.status=''; return true;\" TITLE=\"click here to test \'$file\'\">$file</A><BR>\n");} # non-executable file
else {push (@files," <A HREF=\"$t{'testmycgi'}"."?testmycgi=$t{'testmycgi'}&path=$path&test=$file&run=yes\" onMouseOver=\"window.status='click here to test \\'$file\\' now'; return true;\" onMouseOut=\"window.status=''; return true;\" TITLE=\"click here to test \'$file\'\">$file</A><BR>\n");} # unknown file type
}
@dirs = sort(@dirs); @files = sort(@files); # alpha sort
foreach $dirs(@dirs) {$directorydata .= "$dirs";}
if (!$directorydata) {$directorydata = "<none>";}
foreach $files(@files) {$filedata .= "$files";}
if (!$filedata) {$filedata = "<none>";}
$returnpath = "$path";
$returnpath =~ s/(.*)\/(.*)\/$/$1\//;
}
##########
# SUB COMPOSE INSTRUCTION COPY BLOCK
sub instblock {
$instructions = <<"Inst";
<TR VALIGN=TOP><TD> </TD><TD>$fnt <FONT COLOR=$c1><B>TestMy.CGI</B></FONT> allows you to perform testing and error-reporting (debugging) of your CGI scripts with a simple point-and-click interface. No more command line debugging. No more wading through cryptic logs for relevant errors – <FONT COLOR=$c1><B>TestMy.CGI</B></FONT> makes it easy to navigate through your site's various directories then click on the scripts you want to test.</TD></TR>
<TR VALIGN=TOP><TD ALIGN=RIGHT>$fnt1 1.</TD><TD>$fnt Click on the item in the <B>FILE</B> column (left) that you want to test or input the script name after the "script" prompt (above).</TD></TR>
<TR VALIGN=TOP><TD ALIGN=RIGHT>$fnt1 or</TD><TD>$fnt Type the path in the "path" window and type the script name in the "script" window (above). Click the <B>EXECUTE</B> button and the test results including an itemized list of errors are reported in this table.</TD></TR>
<TR VALIGN=TOP><TD ALIGN=RIGHT>$fnt1 2.</TD><TD>$fnt If the script you want to test is not in this directory (<FONT COLOR=FF0000><B>$path</B></FONT> ), you can type it after the "path" prompt or navigate to it by clicking down into the directories listed under the <B>DIR</B> column. Return to the parent directory by clicking on the path at the top of the directory contents table. $fnt1 Note: Path is from the domain root – For example, <FONT COLOR=$c1>/cgi-bin/projects/</FONT><P>
Thank you for using <FONT COLOR=$c1><B>TestMy.CGI</B></FONT> and for passing it along to your friends and associates.</FONT></TD></TR>
Inst
}
##########
# SUB PARSE
sub inParse {
$method = $ENV{REQUEST_METHOD};
if ($method =~ /get/i) {
$buffer = $ENV{QUERY_STRING};
} elsif ($method =~ /post/i) {
read (STDIN, $buffer, $ENV{CONTENT_LENGTH});
}
##########
# SPLIT THE NAME/VALUE PAIRS
@pairs = split(/&/, $buffer);
foreach $pair(@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$t{$name} = $value;
}
}
1;
exit;
------------------
SteveNet - stevenet@webmarkit.net
Cogito ergo doleo.
[Redigerat av stevenet den 16 nov 2000]
oki....nu blev det mycket :e
Jag är som sagt väldigt grön inom ämnet.
Hur sätter jag rättigheterna till CHMOD 755??
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Om du använder WS_ftp är det bara att markera den fil du vill ändra, högerklicka och välja chmod. 755 = Owner (alla), Group (read+execute), Other (read+execute). Det bör finnas en liknande funktion om du använder ett annat ftp-program.
/Csson
------------------
Erimax.com
Cykelsemester
aha nu faller bitarna på plats :e
Testar lite nu!
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Nytt problem.....jag har fått allt och funka som det ska på servern, men nu är det så att han vill inte skriva till HTML dokumentet där uppdateringen ska ligga och jag vet inte riktigt varför?
Någon som har nån idé??
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Pröva med att ändra rättigheterna på filen till 777, Owner (alla), Group (alla), Other (alla).
------------------
SteveNet - stevenet@webmarkit.net
Cogito ergo doleo.
Nopp funka inte.
Han lägger upp allt som jag skriver i formuläret i olika .txt filer på servern men han gör inte om det till HTML. Jag måste typ ha gjort fel i kodningen.
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Nu förstår jag inte alls... i koden står det ju att scriptet lägger till info i en massa textfiler, och i vissa av dem finns den HTML som du ska inkludera på nyhetssidan. Använd SSI eller PHP för att lägga till dem.
http://www.cgi2000.f2s.com/nyheter/viewheadlines.txt http://www.cgi2000.f2s.com/nyheter/viewnews.txt
Båda innehåller ju HTML...
------------------
Gislaved.net
"Tänk på vad du säger så att du inte säger vad du tänker."
Som sagt jag är helt nollad inom cgi/perl. Jag trode att scriptet var komplett.
Vad använder jag för kodsnutt för att han ska hämta html koderna från .txt filerna??
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Ursäkta om jag lägger mig i, men till 97,5% består felen i att du har konfigerat scriptet fel (rättighter på mappar/filer, och sökvägar).
Dubbelchecka allt och testa igen.
Jag tror inte att du har laddat hem ett gratis script som inte är komplett.
Lycka till
------------------
--KarlTomas
stevenet jag får inte ditt script att funka, är det komplett.?
har samma problem som Kent
------------------
[TeNgBlAd.com] / [NordicDreamDesign]
"Det är inte lätt när det är svårt, men skönt när det går"
Du hittar hela scriptet på http://www.CraigRichards.com/software/
Du har väl använt CHMOD 755?
------------------
Gislaved.net
"Tänk på vad du säger så att du inte säger vad du tänker."
Scriptet är komplett. Anledningen till att jag inte lade upp en länk till det är att det numera är inbakat i ett sharewarescript.
------------------
SteveNet - stevenet@webmarkit.net
Cogito ergo doleo.
Varför funkar det inte då?
Vad får du för felmeddelande? Har du rätt sökväg till Perl?
------------------
Gislaved.net
"Tänk på vad du säger så att du inte säger vad du tänker."