I am trying to redirect all of the output of the script to /dev/tty9. Below is the script, and currently what happens is the script runs in the current terminal and writes 0s to the /dev/tty9 console. I'd like to get the color and everything outputted to that screen. Any help would be appreciated...


Main script:
#!/usr/bin/perl use Net::Ping; + # Module to check a remote host for reachability use Curses; + # Module to allow the use of system's curses $data_file="nms.systems2"; + # File which holds network node data open(DAT, $data_file) || die("COULD NOT OPEN SYSTEMS FILE: $!"); @raw_data=<DAT>; + # Array for holding node data close(DAT); $screen="/dev/tty9"; open(SAVEOUT, ">&STDOUT") || die("COULD NOT DUP STDOUT: $!"); open(STDOUT, ">", $screen) || die("COULD NOT REOPEN STDOUT ON $screen: + $!"); # Redirects standard output to $screen initscr(); + # Show header start_color(); init_pair(1, COLOR_CYAN, COLOR_BLACK); attron(COLOR_PAIR(1)); addstr(1, ($COLS -19) / 2, "Connectivity Status"); $y=0; + # Center line to split sides (comment out if not needed) while ($y != 20) { addstr(3+$y, 40, "|"); $y++; } attroff(COLOR_PAIR(1)); raw(); refresh(); foreach $system (@raw_data) { chop($system); ($ipaddr,$identity,$row,$col)=split(/\|/,$system); $p=Net::Ping->new("icmp"); if ($p->ping($ipaddr,1)) { start_color(); init_pair(2, COLOR_GREEN, COLOR_BLACK); + # If system is up, show output as green attron(COLOR_PAIR(2)); addstr($row, $col, "$identity"); + # Output information to specific location addstr($row+1, $col, " UP"); attroff(COLOR_PAIR(2)); } else { start_color(); init_pair(3, COLOR_RED, COLOR_BLACK); + # If system is down, show output as red attron(COLOR_PAIR(3)); addstr($row, $col, "$identity"); + # Output information to specific location addstr($row+1, $col, " DOWN"); attroff(COLOR_PAIR(3)); } refresh(); } endwin(); close(SAVEOUT); close(STDOUT);

nms.systems2 file:
127.0.0.1|gateway1|3|18 127.0.0.1|gateway2|3|54 127.0.0.1|system01|6|6 127.0.0.1|system02|6|18 127.0.0.1|system03|6|30 127.0.0.1|system11|6|42 127.0.0.1|system12|6|54 127.0.0.1|system13|6|66 127.0.0.1|system04|9|6 127.0.0.1|system05|9|18 127.0.0.1|system06|9|30 127.0.0.1|system14|9|42 127.0.0.1|system15|9|54 127.0.0.1|system16|9|66 127.0.0.1|system07|12|6 127.0.0.1|system08|12|18 127.0.0.1|system09|12|30 127.0.0.1|system17|12|42 127.0.0.1|system18|12|54 127.0.0.1|system19|12|66 127.0.0.1|system10|15|6 127.0.0.1|system20|15|42 127.0.0.1|system21|15|54 127.0.0.1|system22|15|66 127.0.0.1|system23|18|42 127.0.0.1|system24|18|54

In reply to output script to /dev/tty9 by jbush82

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.