Today we once again venture into the world of Perl CGI (Common Gateway Interface) on our Apache/PHP/MySql CentOS web server, this time to investigate using the Perl CGI to show some file information via the Perl access to the Linux operating system file information via Perl syntax:
if (-e $filename) { print "$filename found."; }
if (-d $filename) { print "$filename is a directory."; }
if (-r $filename) { print "$filename is readable."; }
if (-w $filename) { print "$filename is writable."; }
$filesz = -s "$filename"; # shows size of the file
Here is a live link for today’s tutorial where we show some server-side abilities of Perl as your CGI language of choice, as an alternative to the PHP in Apache/PHP/MySql that we normally associate with CentOS (maybe?!) … so maybe we should say Apache/PHP/MySql/PerlCGI … the latter not to be confused with that brilliant policewoman in Argentinian Riot Control whose name happens to be Poyle or is that Pearl.
Helpful for this Perl tutorial was Perl and CGI for the World Wide Web by Elizabeth Castro … thanks heaps!
Will leave you with some downloadable programming Perl source code you could call info_on_file.cgi supervised by some HTML code containing the calling form called info_on_file.html building on the previous Perl CGI Email Primer Tutorial as shown below.
Previous relevant Perl CGI Email Primer Tutorial is shown below.
Today we again venture into the world of CGI (Common Gateway Interface) on our Apache/PHP/MySql web server, this time to investigate using the Perl CGI to send emails via the Linux sendmail command.
Found with the use of sendmail there are configurations you probably shouldn’t touch, that you should work “with” (rather than against … doh!) … and for advice on this would strongly suggest getting the local web server advice on this via the command perldoc -q “How do I send mail” … would like to say that this idea was dreamed up by yours truly, but yet again, and again, and again, and again, and again (are you getting bored because I’m not … it’s a wet day), and again, and again, and again, and again it was an Open Source (and again) link here that helped. And to get here did this search (notice how CentOS is mentioned … ie. get specific).
This last bit is separate to (and on top of) testing code on a local web server (here we have MAMP for Apache/PHP/MySql Perl CGI) … all these Perl CGIs go through that level of testing first, way before they go to any real web server (would highly recommend this).
Have been meaning for three tutorials now to mention the Apache Error Log (called /Applications/MAMP/logs/apache_error.log here on MAMP (will be different location for other web servers)) which can guide you through Perl CGI (or other brands of CGI) error issues. This makes sense (as a place to look) because the web server (Apache) sits above the CGI code, which sits next to your HTML/(PHP)/Javascript/CSS code, which, today, have the role of providing the HTML form whose action goes to Perl CGI after validation goes through Javascript (remember Javascript Form Validation Primer Tutorial). Have a look at a bit of what such a log looks like here.
Here is a live link for today’s tutorial.
With all Perl tutorials, like Perl and CGI for the World Wide Web by Elizabeth Castro … thanks heaps!
Will leave you with some downloadable programming Perl source code you could call email_sender.cgi supervised by some HTML code containing the calling form called email_sender.html
Anything you want to ask? No? Well … we’ll be off then. Bye for now, and hope you try the live link and enjoy the little mathematical tidbits in the emails.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
18 Responses to Perl CGI File Information Primer Tutorial