Avatar billede herbie4ever Nybegynder
02. februar 2002 - 19:04 Der er 22 kommentarer og
1 løsning

Hjælp!! mig med perl scripts ? Forum'er , E-cards m.v til hjemmeside.

Jeg er efter over 100 timers forsøg på at sætte Perl scrips op på min hjemmeside ved at gå amok, HJÆLP!!

Først lidt info om min server:
Server (ADUX Secure Linux FTP server) [server080.adux.dk]
Det tyder på det er en Linux server, eller hva ??

Jeg er total nørd til dette så bær over med mig hvis der er nogle dumme sprøgsmål.

Jeg har i den seneste tid forsøgt at køre et perl script fra Matts Script Archive et simpelt forum som jeg ville have på min hjemmeside, og idag har jeg forsøgt at køre et E-postkort perl script, så man kan sende postkort til venner m.v.

Hver gang jeg har tilpasset dem og rette Variables til, prøver jeg at køre dem og får en "500 Internal Server Error".

Jeg prøver og prøver og kan det mislykkedes hver gang, jeg har pointet stierne korrekt tro jeg nok og chmod som foreskrevet, ligeledes er stien til perl også korrekt #!/usr/bin/perl.

Det jeg spørger jer om, er der nogen derude evt i Lyngby området der kan hjælpe mig evt. kigge på scriptsne eller er der nogen jeg kan betale for at sætte disse to scrips op for mig på min hjemmside?

Gode forslag til hvad jeg gør galt er MEGET velkommen.

Ligeledes skal jeg høre om der er nogen måde jeg kan spørge min FTP  (Cute ftp) om hvad: The system path til nedestående er?
-------
$mail_message = "/www09/web/untrac/postcard/mail.txt";
The system path to the text file mail.txt.

$mailprog = '/usr/lib/sendmail -t';
The system path to the sendmail program on your server. The -t is there for security reasons.

$date_command = "/usr/bin/date";
The system path to the date command.
--------------

Tak 1000 tak, i ville redde mig hvis jeg kan komme over dette kapitel.
Avatar billede enobe Nybegynder
02. februar 2002 - 19:56 #1
hvad står der i din error.log?
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 20:00 #2
Hvor kan jeg finde min error log?

I ftp'en?
Avatar billede enobe Nybegynder
02. februar 2002 - 21:15 #3
ja, du har sikkert en mappe, der hedder noget med logs
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 22:00 #4
Jo Jeg Fandt min log mappe prøved at sende et postkort og fik 500 server error.

det eneste der stod i loggen var:
21:56:58 62.79.26.163 www.herbie.dk POST /cgi-bin/postcard.pl HTTP/1.1 - 500 601 601 0 80 "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)" http://www.herbie.dk/postcards/postcard.html

Tak for din hjælp.
Avatar billede ztyxx Nybegynder
02. februar 2002 - 22:05 #5
prøv at poste dit postcard.pl her en gang
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 22:07 #6
Her kommer Postcard.pl

#!/usr/bin/perl
#######################################################
#postcard.pl 1.4                   
#                                           
#by Command-O Software                       
#http://www.command-o.com   
#               
#Programmer: Kendall Comey                                   
#                                       
#For support, write: support@command-o.com
#Copyright, 1997, All Rights Reserved               
#
#By using this script Licensee agrees to all terms of the License
#Agreement.                               
#
#If you find this script useful, we would appreciate a
#donation to keep this service active for the community.
#Command-O Software, P.O. Box 12200, Jackson WY 83002
#######################################################
# Client Customization Variables

#Set the correct paths, if cgi-lib.pl and postcard.setup are not in cgi-bin.
require 'cgi-lib.pl';
require 'postcard.setup';

############################################################
# CHANGING ANYTHING BELOW THIS LINE WITHOUT THE EXPRESS PERMISSION   
#  OF COMMAND-O SOFTWARE IS A VIOLATION OF THE LICENSE AGREEMENT   
############################################################

#Turn off Perl buffering
$| = 1;

#Read and parse the form data
&ReadParse(*input);

#Assign variables

$date = `$date_command +"%m\/%d\/%Y"`;
$date =~ s/\n*$//;
$current_date = $date;
$test = 0;
$time = time;
$cardlist_temp = "$cardlist" . "_" . "temp";

if ($input{'send'} ne "") {
print "Location: $url_of_postcard_html", "\n\n";
}
elsif ($input{'pickup'} ne "") {
print "Location: $url_of_pickup_html", "\n\n";
}
elsif ($input{'preview'} ne "") {
    print &PrintHeader;
    &check_required;
    &select_card_number;
    &print_preview;
}
elsif ($input{'submit'} ne "")    {
    print &PrintHeader;
    &send_card;
    &delete_old_cards;

}
elsif ($ENV{'QUERY_STRING'} ne "")    {
    print &PrintHeader;
    &pickup_card;
}

#########################################################################
sub delete_old_cards    {
$current_time = time;

$delete_date = $current_time - ($days * 86400);

open (TEMP, ">$cardlist_temp") || die ("Could not open $cardlist_temp");
flock (TEMP, 2);
open (CARD, "$cardlist") || die ("Could not open $cardlist");
flock (CARD, 2);
    while (<CARD>)    {
    ($number, $from, $from_email, $message, $to, $notify, $image, $date_time, $date) = split(/\|/, $_);
        if ($delete_date < $date_time)    {
        print TEMP "$_";
        }
    }
flock (CARD, 8);
flock (TEMP, 8);
close (TEMP);
close (CARD);
rename ($cardlist_temp, $cardlist);
}

############################################################
sub check_required    {
if ($input{'address'} eq "")    {
print "You must specify the email address of the recipient in order for this ";
print "postcard to be sent. Please use the back button on your browser to ";
print "enter the email address and then submit the postcard again. Thank you.";
exit;
}
unless ($input{'address'} =~ /^[\w-.]+\@[\w-.]+$/)    {
print "Invalid email address. Please use the back button on your browser to ";
print "enter the correct email address and then submit the postcard again. ";
print "Thank you.";
exit;
}
if ($input{'name'} eq "")    {
print "You must specify a name for the recipient of this postcard in order for this ";
print "postcard to be sent. Please use the back button on your browser to ";
print "enter the name of the recipient and then submit the postcard again. Thank
you.";
exit;
}
if ($input{'sender'} eq "") {
print "You must specify a name for the sender of this postcard in order for this ";
print "postcard to be sent. Please use the back button on your browser to ";
print "enter the name of the sender and then submit the postcard again. Thank you.";
exit;
}
if ($input{'notify'} ne "" && $input{'senderemail'} eq "")    {
print "You must enter your email address in order to be notified when your postcard ";
print "is picked up. Please use the back button on your browser to ";
print "enter your email address or deselect the notification checkbox and then ";
print "submit  the postcard again. Thank you.";
exit;
}
if ($input{'senderemail'} ne "")    {
unless ($input{'senderemail'} =~  /^[\w-.]+\@[\w-.]+$/) {
print "Invalid email address. Please use the back button on your browser to ";
print "enter the correct email address and then submit the postcard again. ";
print "Thank you.";
exit;
}
}
}

############################################################
#Preview postcard
sub print_preview    {
open (PAGE, "$preview_postcard") || die ("I am sorry, but I was unable to open the
file $preview_postcard.");
    while (<PAGE>)        {
    s/%%date%%/$date/g;
    s/%%name%%/$input{'name'}/g;
    s/%%sender%%/$input{'sender'}/g;
    s/%%message%%/$input{'message'}/g;
    s/%%address%%/$input{'address'}/g;
    s/%%senderemail%%/$input{'senderemail'}/g;
    s/%%notify%%/$input{'notify'}/g;
    s/%%image%%/$image/g;
    print $_;
    }
    close (PAGE);
}

############################################################
#Put in the correct photograph
sub select_card_number {
$image = $input{'card_number'};
}

############################################################
sub send_card    {
#Assign a userid
srand (time|$$);
$userid = int (rand(1000));
$userid .= "$$";

#Print out thank you message
open (PAGE, "$thank_you") || die ("I am sorry, but I was unable to open the file
$thank_you.");
while (<PAGE>)        {
    s/%%name%%/$input{'name'}/g;
    print $_;
}
close (PAGE);

#Write form data to file
open (DATABASE, ">>$cardlist") || die ("I am sorry, but I was unable to open the file.");

#Remove any pipe symbols from input
$input{'sender'} =~ s/\|//g;
$input{'message'} =~ s/\|//g;
$input{'name'} =~ s/\|//g;
$input{'senderemail'} =~ s/\|//g;
$input{'message'} =~ s/\s+/ /g;

flock (DATABASE, 2);

print DATABASE "$userid\|$input{'sender'}\|$input{'senderemail'}\|$input{'message'}\|";
print DATABASE "$input{'name'}\|$input{'notify'}\|$input{'card_number'}\|$time\|$date\n";

flock (DATABASE, 8);
close (DATABASE);

#Send e-mail to recipient
open (MAIL, "|$mailprog $input{'address'}") || die "Can't open $mailprog!\n";
    print MAIL "Reply-to: $input{'senderemail'}\n";
    print MAIL "From: $input{'senderemail'}\n";
    print MAIL "To: $input{'address'}\n";
    print MAIL "Subject: $subject\n\n";
open (PAGE, "$mail_message") || die ("I am sorry, but I was unable to open the file
$thank_you.");
    while (<PAGE>)        {
    s/%%sender%%/$input{'sender'}/g;
    s/%%userid%%/$userid/g;
    print MAIL $_;
    }
close (PAGE);
close (MAIL);
}

############################################################
sub pickup_card {
#Open card.list file
open (DATABASE, "$cardlist") || &CgiDie ("I am sorry, but I was not able to open the
data file.");
flock (DATABASE, 2);
#Assign database to list array
    @list = <DATABASE>;
flock (DATABASE, 8);
close (DATABASE);

#Split array into scalar variables
foreach $list (@list) {
($userid, $sender, $senderemail, $message, $name, $notify, $image, $date_time, $date) = split
(/\|/, $list);

#Compare form input to $userid
if ($input{'id_num'} eq $userid && $input{'id_num'} ne "") {
$test = 1;
&print_html;
if ($notify eq "on") {
&notify;
}
last;
}
}

if ($test == 0) {
&invalid_id;
}
}
############################################################
sub print_html {
open (PAGE, "$show_postcard") || die ("I am sorry, but I was unable to open the file
$thank_you.");
    while (<PAGE>)        {
    s/%%sender%%/$sender/g;
    s/%%date%%/$date/g;
    s/%%name%%/$name/g;
    s/%%message%%/$message/g;
    s/%%image%%/$image/g;
    print  $_;
            }
close (PAGE);
}

############################################################
#Send e-mail to sender
sub notify {
$date =~ s/\n*$//;
open (MAIL, "|$mailprog $senderemail") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $reply_to\n";
print MAIL "From: $reply_to\n";
  print MAIL "To: $senderemail\n";
  print MAIL "Subject: Postcard Picked-up\n\n";
  print MAIL "The postcard you sent to $name, from $company, was picked up on ";
print MAIL "$date. \nThank you.";
close (MAIL);
}

############################################################
#Invalid user message
sub invalid_id {
print <<EOT;
Sorry, but you have entered an invalid card ID number. Please use the back button
on your browser to re-enter the correct card ID.
EOT
exit;
}
Avatar billede ztyxx Nybegynder
02. februar 2002 - 22:15 #7
ligger cgi-lib.pl og postcard.setup også i dit cgi-bin
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 22:20 #8
Yep begge ligger i cgi-bin og resten af filerne ligger i mappen www/postcards/.../
Avatar billede ztyxx Nybegynder
02. februar 2002 - 22:21 #9
har du prøvet at chmod´e hele baduljen til 777??
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 22:23 #10
Jeg mener at jeg har placeret alle filerne rgtigt, det er bare sprøgsmålet om jeg har redigeret postcard.setup correct. her er en kopi af den:


#Client Customization Variables
####################################################
$url_of_postcard_html = "http://herbie.dk/postcards/postcard.html";
# This is the url that points to the html file postcard.html.

$url_of_pickup_html = "http://herbie.dk/postcards/pickup.html";
# This is the url that points to the html file pickup.html.

$preview_postcard = "/domains/http://herbie.dk/postcards/preview.html";
# This is the system path to the html file preview.html.

$cardlist = "/domains/http://herbie.dk/postcards/card.list";
# This is the system path to the file which will have the postcard database written to it.

$thank_you = "/domains/http://herbie.dk/postcards/thank_you.html";
# This is the system path to the html file thank_you.html.

$show_postcard.html = "/domains/http://herbie.dk/postcards/show_postcard.html";
# This is the system path to the html file show_postcard.html.

$reply_to = "info\@bug-in.com";
# The return email address you would like specified. You need to backslash the @ sign as shown

$company = "Bug In Copenhagen 2002";
# Your name or your company name. Used in email.

$subject = "www-bug-in.com A Postcard for You!";
# Subject of email to recipient of postcard.

$mail_message = "http://herbie.dk/postcards/mail.txt";
# The system path to the text file mail.txt.

$mailprog = "/usr/sbin/sendmail -t";
# The system path to the sendmail program on your server. Leave the -t there.

$date_command = "/bin/date";
# The system path to the date command.

$days = "14";
# The number of days after which a postcard is no longer retrievable.

1; #Leave this line alone
Avatar billede ztyxx Nybegynder
02. februar 2002 - 22:27 #11
har du prøvet at sætte system stierne til
$preview_postcard = "/domains/herbie.dk/postcards/preview.html";
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 22:38 #12
Nu har jeg ændret det , nu set det sådan ud:

#Client Customization Variables
####################################################
$url_of_postcard_html = "http://herbie.dk/postcards/postcard.html";
# This is the url that points to the html file postcard.html.

$url_of_pickup_html = "http://herbie.dk/postcards/pickup.html";
# This is the url that points to the html file pickup.html.

$preview_postcard = "/domains/herbie.dk/postcards/preview.html";
# This is the system path to the html file preview.html.

$cardlist = "/domains/herbie.dk/postcards/card.list";
# This is the system path to the file which will have the postcard database written to it.

$thank_you = "/domains/herbie.dk/postcards/thank_you.html";
# This is the system path to the html file thank_you.html.

$show_postcard.html = "/domains/herbie.dk/postcards/show_postcard.html";
# This is the system path to the html file show_postcard.html.

$reply_to = "info\@bug-in.com";
# The return email address you would like specified. You need to backslash the @ sign as shown

$company = "Bug In Copenhagen 2002";
# Your name or your company name. Used in email.

$subject = "www-bug-in.com A Postcard for You!";
# Subject of email to recipient of postcard.

$mail_message = "/domains/herbie.dkpostcards/mail.txt";
# The system path to the text file mail.txt.

$mailprog = "/usr/sbin/sendmail -t";
# The system path to the sendmail program on your server. Leave the -t there.

$date_command = "/bin/date";
# The system path to the date command.

$days = "14";
# The number of days after which a postcard is no longer retrievable.

1; #Leave this line alone
Avatar billede ztyxx Nybegynder
02. februar 2002 - 22:43 #13
jeg har kigget på adux.dk´s supportside, http://www.adux.dk/support/support_faq.php3?Keyword=CGI&Side=2 , og der står
Spørgsmål: "Hvad er den fysiske sti til mit webhotel?."

Svar: "Den fysiske sti er altid: $ENV{DOCUMENT_ROOT}

HTML-filerne ligger i "$ENV{DOCUMENT_ROOT}

/cgi-bin har stien "$ENV{DOCUMENT_ROOT}/../cgi-bin/

i forbindelse med .htaccess filer er det desværre nødvendigt at specificere den og der er den /domains/www.hotelnavn.dk/"

så mo ikke det skal se sådan ud:
$preview_postcard = "/domains/www.herbie.dk/postcards/preview.html"; 
og så fremdeles
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 22:51 #14
Du tror det er løgn men det vil bare ikke fungere.

Hvis du er interesseret kan jeg sende dig en kopi af, mit brugernavn og password til min ftp så kan du selv teste det live?

Så skal jeg bare have din e-mail.

Lige nu ser postcard.setup således ud:

#Client Customization Variables
####################################################
$url_of_postcard_html = "http://herbie.dk/postcards/postcard.html";
# This is the url that points to the html file postcard.html.

$url_of_pickup_html = "http://herbie.dk/postcards/pickup.html";
# This is the url that points to the html file pickup.html.

$preview_postcard = "/domains/www.herbie.dk/postcards/preview.html";
# This is the system path to the html file preview.html.

$cardlist = "/domains/www.herbie.dk/postcards/card.list";
# This is the system path to the file which will have the postcard database written to it.

$thank_you = "/domains/www.herbie.dk/postcards/thank_you.html";
# This is the system path to the html file thank_you.html.

$show_postcard.html = "/domains/www.herbie.dk/postcards/show_postcard.html";
# This is the system path to the html file show_postcard.html.

$reply_to = "info\@bug-in.com";
# The return email address you would like specified. You need to backslash the @ sign as shown

$company = "Bug In Copenhagen 2002";
# Your name or your company name. Used in email.

$subject = "www-bug-in.com A Postcard for You!";
# Subject of email to recipient of postcard.

$mail_message = "/domains/www.herbie.dk/postcards/mail.txt";
# The system path to the text file mail.txt.

$mailprog = "/usr/sbin/sendmail -t";
# The system path to the sendmail program on your server. Leave the -t there.

$date_command = "/bin/date";
# The system path to the date command.

$days = "14";
# The number of days after which a postcard is no longer retrievable.

1; #Leave this line alone
Avatar billede ztyxx Nybegynder
02. februar 2002 - 22:54 #15
ztyxx@ztyxx.f2s.com
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 22:59 #16
Hvis det er ok, så sender jeg det imorgen tidelig, jeg er på vej i seng.

Mvh Thomas
Avatar billede ztyxx Nybegynder
02. februar 2002 - 23:02 #17
oki, men ved ikke lige hvornår imorgen jeg får tid, men ellers kan jeg kigge på det nu, og så droppe en mail til dig om jeg får det til at virke??
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 23:08 #18
ok jeg sender det om lidt skal lige finde dem
Avatar billede ztyxx Nybegynder
02. februar 2002 - 23:09 #19
oki :-)
Avatar billede ztyxx Nybegynder
02. februar 2002 - 23:23 #20
har modtaget email, kigger på det med det samme
Avatar billede herbie4ever Nybegynder
02. februar 2002 - 23:28 #21
1000 tak, jeg håber du hitter ud af det.

Mvh Thomas
Avatar billede ztyxx Nybegynder
03. februar 2002 - 10:27 #22
så virker postkortscriptet :-)
Avatar billede ztyxx Nybegynder
03. februar 2002 - 12:34 #23
takker for point :-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester