Good day Monks! I have been searching the web and trying different variations of code so that the end user via a web interface can see all of the server backup logs and select anyone of them to read the log. I am working on a test system which is RHEL 6. There is the dir "/var/log/vista/stcr2tsvr/" where the backup logs are stored and it has files in it. I have even chmod 777 all of the dirs. and files (Just for testing)When I call the script from IE I get the standard server error and when I tail /var/log/httpd/error_log I am presented with the following:

Tue Feb 24 14:11:10 2015] [error] [client 10.*.*.*] (2)No such file or + directory: exec of '/var/www/cgi-bin/rdp_backuplogs_test' failed [Tue Feb 24 14:11:10 2015] [error] [client 10.*.*.*] Premature end of +script headers: rdp_backuplogs_test
I am unsure where I am going wrong with the code:

#!usr/bin/perl use strict; use CGI; my $list = new CGI; my $fileDir = "/var/log/vista/stcr2tsvr/"; my @files; print $fileDir; opendir DIR, "$fileDir"; @files = grep(/\.log$/,readdir(DIR)); ## Example file to read 2015 +0210-dubr3psvr-backup.log closedir DIR; print $list->header("text/html"), $list->start_html("Files in $fileDir"), $list->p("These are the files in $fileDir"); foreach my $file (@files) { print $list->p( $list->a({-href=>$file}, $file) ); } print $list->end_html;

I am learning perl and have been able to write several other processes for the web application which is a sysadmin portal for our Linux environment in both perl and BASH scripts. I have seen examples of this code here and on other sites but I can’t seem to figure out what is wrong. Thanks in advance for looking at this and please excuse my ignorance.


In reply to Display DIR files and output in html to select a file by vhaphisasset

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.