From owner-freebsd-questions Sun Oct 3 4:21: 5 1999 Delivered-To: freebsd-questions@freebsd.org Received: from scotty.masternet.it (scotty.masternet.it [194.184.65.2]) by hub.freebsd.org (Postfix) with ESMTP id 4C7B714D70 for ; Sun, 3 Oct 1999 04:20:54 -0700 (PDT) (envelope-from gmarco@scotty.masternet.it) Received: from suzy (modem34.masternet.it [194.184.65.44]) by scotty.masternet.it (8.9.3/8.9.3) with ESMTP id NAA81263; Sun, 3 Oct 1999 13:20:45 +0200 (CEST) (envelope-from gmarco@scotty.masternet.it) Message-Id: <4.2.0.58.19991003131442.0133cf00@194.184.65.4> X-Sender: gmarco@scotty.masternet.it X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.0.58 Date: Sun, 03 Oct 1999 13:25:09 +0200 To: "Langa Kentane" , "FreeBSD" From: Gianmarco Giovannelli Subject: Re: Help with smaill perl script Cc: freebsd@scotty.masternet.it In-Reply-To: <007e01bf0d83$f609d6a0$0b02a8c0@sunnet.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG At 03/10/99, Langa Kentane wrote: >Hi >I don't know how to use perl and getting a book on it and reading would take >too long to solve the small problem that I have. > >What I want to do is to have a web page showing all the user's home pages >that will update dinamically. What I mean it that when you access this >page it should show you all the user names and link that to the user's home >page. When I add a new user it must show immediately as soon as I hit >reload on the browser Here is the CGI.pm (lunch is over :-) #### cut here ### #!/usr/bin/perl use CGI qw(:standard :html3 :netscape); use CGI::Carp; $servername = "kirk.giovannelli.it"; $public = "public_html"; $title = "Your title"; $author = "Your name"; $background = "sample pic"; $dtd="-//W3C//DTD HTML 3.2//EN"; print header(); print start_html( -title=>"$title", -author=>"$author", -dtd=>"$dtd", -background=>"$background", ),"\n"; setpwent; while(@list = getpwent){ $login = $list[0]; $name = $list[6]; $uid = $list[2]; if ($uid >= 999){ $home = $list[7]; if (-e "$home/$public"){ print a({href=>"http://$servername/~$login/"},"$name"),br; } } } print end_html(); ### cut ###### I assume: Your perl is > 5.05 and it is in /usr/bin/perl . You have to chmod 755 this script before it can be executed from web. You have Apache configured to use .pl as cgi binary, otherwise rename it as you want (i.e. users.cgi) I don't know which kind of html rendering do you want, but you can modify without too much effort. If you don't know the CGI.pm coding style, simply add the HTML tags in this way: print "
HI

"; You can use the var inside the print as well... You can try also to reduce part of the code, which is not necessary ... Hope it helps... Best Regards, Gianmarco Giovannelli , "Unix expert since yesterday" http://www.giovannelli.it/~gmarco http://www2.masternet.it To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message