when i execute the following code, when the script is done my console (bash) does not show any output. if i use zsh the issue does not happen, but unfortunately i'm not able to use zsh outside my development system. I've narrowed the issue down to something with the children. Here is the code that causes my issues:
#!/usr/bin/perl use strict; use warnings; use Nmap::Parser; my @pids; my $max = 10; my $children = 0; my $net = shift(); if (!defined $net) { $net = "192.168.1"; } foreach my $count (1..10) { my $ipaddress; $ipaddress = $net . "." . $count; my $pid; if($children == $max) { $pid = wait(); $children--; } if(defined($pid = fork())) { if($pid) { #parent $children++; push @pids, $pid; } else { #child my $ssh = my $rdp = " "; my $np = new Nmap::Parser; my $nmap_path = "/usr/bin/nmap"; my $nmap_args = "-Pn -p 22,3389"; $np->parsescan($nmap_path, $nmap_args, $ipaddress); my $host = $np->get_host($ipaddress); my @ports = $host->tcp_ports('open'); foreach my $port (@ports) { if ($port == 22 ) { $ssh = "Y"; } if ($port == 3389 ) { $rdp = "Y" } } printf "%-15s %-4s %-4s\n", $ipaddress, $rdp, $ssh; exit; } } else { print "Error: failed to fork\n"; exit; } } for my $pid(@pids) { waitpid $pid, 0; }
I'm hoping to not use any modules for children and just using built-in methods. Any help is appreciated.

In reply to console output invisible after script exit by adambot

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.