I am having trouble creating a log file for this script, I believe this is the line that is causing the trouble, if I had to guess.

my $con = Win32::Console->new(STD_OUTPUT_HANDLE);

Could someone please point me in the right direction. thanks Steve
use Win32::Console; use Net::Ping; use warnings; use strict; my $host="10.20.0.20"; my $p = Net::Ping->new("icmp", 5, 64); $p->hires(); my $count = 0; my $pGood = 0; my $pBad = 0; open (OUTPUTFILE, ">", "C:\\OUTPUT.TXT")or die $!; $| = 1; my $con = Win32::Console->new(STD_OUTPUT_HANDLE); my $highlight = $FG_GREEN | $BG_BLACK; my $normal_color = $con->Attr; $con->Cls(); print "Host: $host\n"; print "Prot: ICMP\n"; print "Timeout: 5\n"; print "Size: 64\n"; print "\n\n"; (my $x, my $y) = $con->Cursor(); until ($count == 1000) { my ($ret, $duration, $ip) = $p->ping($host, 5.5); if ($ret == 1) { my @timeData = localtime(time); my $durationa = 1000 * $duration; $con->WriteChar("$host [ip: $ip] is alive (packet return time: +$durationa ms", $x, $y); print OUTPUTFILE "<"; print OUTPUTFILE join(' ', @timeData); print OUTPUTFILE "> "; print OUTPUTFILE "$host [ip: $ip] is alive (packet return time +:$durationa ms\n"; $pGood++; my $Goodx = $x; my $Goody = $y + 5; my $Badx = $x + 20; my $Bady = $y + 5; $con->WriteChar("Successful [ $pGood ]", $Goodx, $Goody); $con->WriteChar("Unsuccessful [ $pBad ]", $Badx, $Bady); sleep(1); } else { my @timeData = localtime(time); print OUTPUTFILE "<"; print OUTPUTFILE join(' ', @timeData); print OUTPUTFILE "> "; print OUTPUTFILE "$host [ip: $ip] Dropped.\n"; $con->WriteChar("$host [ip: $ip] Dropped.\n", $x, $y); $pBad++; my $Goodx = $x; my $Goody = $y + 5; my $Badx = $x + 35; my $Bady = $y + 5; $con->WriteChar("Successful [ $pGood ]", $Goodx, $Goody); $con->WriteChar("Unsuccessful [ $pBad ]", $Badx, $Bady); } $count++; }

In reply to Writing to file by SteveS832001

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.