I'm hesitant to make this post, I seem to lack the ability to distinguish between "good" and "bad" posts. I've made one really good one, and one totally moronic one. But I digress....
I've been trying to get the information via the unix finger command outputed to HTML. So far I've only had success by using system () to create an empty file, then using system again to send the output of the finger command to that file. Then, I read in the file, get rid of any spaces greater than 2 (since HTML ignores it anyway) and print it out on seperate lines. Here's what I've got:
use CGI;
$cgi = new CGI;
$cgi->use_named_parameters;
$name = $ENV{'QUERY_STRING'};
$thefile = "/u/sdrupert/public_html/cgi-bin/tempout.finger";
$create = "/usr/bin/touch " . $thefile;
$run = "/.software/local/.admin/bins/bin/finger " . $name . "\@math >>
+ " . $thefile;
$gone = "rm " . $thefile;
system ($create);
system ($run);
open (INFO, "<$thefile");
@ffile = <INFO>;
close (INFO);
system ($gone);
print $cgi->header;
print $cgi->start_html(-title=>'Finger ' . $name . '@math',-bgcolor=>'
+white');
foreach $line (@ffile)
{
$line =~ s/[ ]{2,}/!/g;
@new = split (/!/, $line);
foreach $newline (@new)
{
print $newline . "<br>";
}
}
print $cgi->end_html;
This works, but a) doesn't look great; and b) I'm sure there's a better way out there.
So, if you tried this before, or have any suggestions, or you even think this post makes up for the last one, please leave a comment/response/suggestion/flame. Thanks.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.