426 Part IV . Development To make the (Adelphia web hosting)

426 Part IV . Development To make the program even more useful I ve added the ability to look up the privileges that a given user/host pair has. This shows an example of another type of statement being performed on the MySQL database other than a SELECT. The program is too large to fit into a figure illustration but I ve included the program here and also some sample output in Figure 15-42. #!/usr/bin/perl use DBI; # This program looks up the hosts from which a # given user is allowed to connect. # Also looks up grants for a user, given the @ symbol # in the argument list. $user = $ARGV[0]; # Test to make sure the user entered a username. if (! $user) { print No user specified. Usage:
n ; } $dbh = DBI->connect( DBI:mysql:mysql: ,undef, evh5150 ); if (! $dbh) { print Connection failed!!nn ; die(); } # If there s an @ symbol then the user wants to look up # grants. if ($user =~ m/@/) { ($user,$inhost) = split(/@/, $user); # Make sure the username and host are safe to # send to MySQL. $quoteduser = $dbh->quote($user); $quotedhost = $dbh->quote($inhost); &priv($user,$inhost); } else { # User wants to simply lookup the hosts allowed # for given username. # Make sure the username is safe to # send to MySQL. $quoteduser = $dbh->quote($user);
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Leave a Reply