{"id":9890,"date":"2014-10-01T05:01:51","date_gmt":"2014-09-30T19:01:51","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=9890"},"modified":"2014-10-01T05:01:51","modified_gmt":"2014-09-30T19:01:51","slug":"perl-cgi-file-information-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/perl-cgi-file-information-primer-tutorial\/","title":{"rendered":"Perl CGI File Information Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Perl\/info_on_file.html\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Perl CGI File Information Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Perl\/info_on_file.jpg\" title=\"Perl CGI File Information Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Perl CGI File Information Primer Tutorial<\/p><\/div>\n<p>Today we once again venture into the world of Perl CGI (<a target=_blank title='CGI information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Common_Gateway_Interface'>Common Gateway Interface<\/a>) 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:<\/p>\n<ul>\n<li><code>if (-e $filename) { print \"$filename found.\"; }<\/code><\/li>\n<li><code>if (-d $filename) { print \"$filename is a directory.\"; }<\/code><\/li>\n<li><code>if (-r $filename) { print \"$filename is readable.\"; }<\/code><\/li>\n<li><code>if (-w $filename) { print \"$filename is writable.\"; }<\/code><\/li>\n<li><code>$filesz = -s \"$filename\";  # shows size of the file<\/code><\/li>\n<\/ul>\n<p>Here is a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Perl\/info_on_file.html\" title='Click picture.'>live link<\/a> for today&#8217;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?!) &#8230; so maybe we should say Apache\/PHP\/MySql\/PerlCGI &#8230; the latter not to be confused with that brilliant policewoman in <a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/Cuerpo_Guardia_de_Infanter%C3%ADa' title='Cuerpo Guardia de Infanter\u00eda information from Wikipedia ... thanks.'>Argentinian Riot Control<\/a> whose name happens to be <strike>Poyle<\/strike> or is that Pe<strike>a<\/strike>rl.<\/p>\n<p>Helpful for this Perl tutorial was <i>Perl and CGI for the World Wide Web<\/i> by Elizabeth Castro &#8230; thanks heaps!<\/p>\n<p>Will leave you with some downloadable programming Perl source code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Perl\/info_on_file.cgi_GETME\" title='info_on_file.cgi'>info_on_file.cgi<\/a> supervised by some HTML code containing the calling form called <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Perl\/info_on_file.html_GETME\" title='info_on_file.html'>info_on_file.html<\/a> building on the previous <a target=_blank href='#pcrpt' title='Perl CGI Email Primer Tutorial'>Perl CGI Email Primer Tutorial<\/a> as shown below.<\/p>\n<hr \/>\n<p id='pcrpt'>Previous relevant <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=7451' title='Perl CGI Email Primer Tutorial'>Perl CGI Email Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/email_sender.html\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Perl CGI Email Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Perl_CGI_Email.jpg\" title=\"Perl CGI Email Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Perl CGI Email Primer Tutorial<\/p><\/div>\n<p>Today we again venture into the world of CGI (<a target=_blank title='CGI information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Common_Gateway_Interface'>Common Gateway Interface<\/a>) on our Apache\/PHP\/MySql web server, this time to investigate using the Perl CGI to send emails via the Linux <i><a target=_blank title='sendmail information via Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Sendmail'>sendmail<\/a><\/i> command.<\/p>\n<p>Found with the use of <i><a target=_blank title='sendmail syntax advice from Computerhope ... thanks' href='http:\/\/www.computerhope.com\/unix\/usendmai.htm'>sendmail<\/a><\/i> there are configurations you probably shouldn&#8217;t touch, that you should work &#8220;with&#8221; (rather than against &#8230; doh!) &#8230; and for advice on this would strongly suggest getting the local web server advice on this via the command <i>perldoc -q &#8220;How do I send mail&#8221;<\/i> &#8230; 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&#8217;m not &#8230; it&#8217;s a wet day), and again, and again, and again, and again it was an Open Source (and again) link <a target=_blank title='CentOS Perl sendmail help ... thanks' href='http:\/\/stackoverflow.com\/questions\/1054029\/why-cant-i-send-email-using-perl-cgi-script-on-centos'>here<\/a> that helped.  And to get here did this <a target=_blank title='CentOS sendmail perl ... at Google ... thanks' href='https:\/\/www.google.com.au\/?gfe_rd=ctrl&#038;ei=3s4rU6TsBsHC8gfOtYHAAw&#038;gws_rd=cr#q=CentOS+sendmail+perl'>search<\/a> (notice how CentOS is mentioned &#8230; ie. get specific).<\/p>\n<p>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) &#8230; all these Perl CGIs go through that level of testing first, way before they go to any real web server (would highly recommend this).<\/p>\n<p>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  <a target=_blank title='Javascript Form Validation Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=1431'>Javascript Form Validation Primer Tutorial<\/a>).   Have a look at a bit of what such a log looks like <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/Perl_CGI_Email-99of.jpg\" title='Look of Apache Error Log on local web server MAMP'>here<\/a>.<\/p>\n<p>Here is a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/email_sender.html\" title='Click picture.'>live link<\/a> for today&#8217;s tutorial.<\/p>\n<p>With all Perl tutorials, like <i>Perl and CGI for the World Wide Web<\/i> by Elizabeth Castro &#8230; thanks heaps!<\/p>\n<p>Will leave you with some downloadable programming Perl source code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/email_sender.cgi_GETME\" title='email_sender.cgi'>email_sender.cgi<\/a> supervised by some HTML code containing the calling form called <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/email_sender.html_GETME\" title='email_sender.html'>email_sender.html<\/a><\/p>\n<p>Anything you want to ask?  No?  Well &#8230; we&#8217;ll be off then.   Bye for now, and hope you try the live link and enjoy the little mathematical tidbits in the emails.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d7451' onclick='var dv=document.getElementById(\"d7451\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Perl\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d7451' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d9820' onclick='var dv=document.getElementById(\"d9890\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=operating-system-2\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d9890' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/perl-cgi-file-information-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[195,196,213,427,576,707,885,916,997,1319,1411],"class_list":["post-9890","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-centos","tag-cgi","tag-clientserver","tag-file-system","tag-html","tag-linux","tag-operating-system-2","tag-perl","tag-programming","tag-tutorial","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9890"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=9890"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9890\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=9890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=9890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=9890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}