Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 03 Oct 1999 13:25:09 +0200
From:      Gianmarco Giovannelli <gmarco@scotty.masternet.it>
To:        "Langa Kentane" <evablunted@earthling.net>, "FreeBSD" <Freebsd-questions@FreeBSD.ORG>
Cc:        freebsd@scotty.masternet.it
Subject:   Re: Help with smaill perl script
Message-ID:  <4.2.0.58.19991003131442.0133cf00@194.184.65.4>
In-Reply-To: <007e01bf0d83$f609d6a0$0b02a8c0@sunnet.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
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 "<TABLE><TR><TD>HI</TD></TR></TABLE><BR>";

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.2.0.58.19991003131442.0133cf00>