$ ping -ncl perlmonks.org ping: bad number of packets to transmit. $ ping -ncl www.perlmonks.org ping: bad number of packets to transmit. $ #### -n Numeric output only. No attempt will be made to lookup symbolic names for host addresses. -c count Stop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the time‐ out expires. -l preload If preload is specified, ping sends that many packets not wait‐ ing for reply. Only the super-user may select preload more than 3. #### (uiserver):u61210220:~/pmimage$ pwd >1.pitty2 (uiserver):u61210220:~/pmimage$ cat 1.pitty2 /kunden/homepages/9/d349337426/htdocs/pmimage (uiserver):u61210220:~/pmimage$ #### Put file to server(y/n)?: y server dir is perlmonks parameter array is perlmonks Net::SFTP::Foreign=HASH(0x55825b47bcc8) Couldn't create remote directory: Failure error is Couldn't create remote directory: Failure #### sub createDir { use 5.011; use Net::SFTP::Foreign; my ( $dirName, $sftp ) = @_; my $success = $sftp->mkdir($dirName) or handleDirCreateError( @_, $sftp->error ); return $success; } sub handleDirCreateError { use 5.011; use Net::SFTP::Foreign; use Net::SFTP::Foreign::Constants qw(:error); my ( $dirName, $sftp, $error ) = @_; say "parameter array is @_"; say "error is $error"; return $error; } #### $ cat 6.fork.pl #!/usr/bin/perl -w use 5.011; my $start = time; if (fork() == 0) { # arm the alarm clock alarm(10); # create a child process that sleeps system("ping www.google.com >5.fork.txt"); exit(0); } say "relevant processes with pstree command:"; system("pstree -Apal $$"); while((my $pid = wait()) != -1) { say "$pid terminated" } system("cat 5.fork.txt"); say time-$start, " ? <-ten seconds elapsed from forked process" __END__ $ #### $ ./6.fork.pl relevant processes with pstree command: 6.fork.pl,6780 -w ./6.fork.pl |-6.fork.pl,6781 -w ./6.fork.pl | `-sh,6783 -c ping www.google.com >5.fork.txt `-pstree,6782 -Apal 6780 6781 terminated PING www.google.com(sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004)) 56 data bytes 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=1 ttl=54 time=30.6 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=3 ttl=54 time=147 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=4 ttl=54 time=16.3 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=5 ttl=54 time=137 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=6 ttl=54 time=123 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=7 ttl=54 time=20.5 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=8 ttl=54 time=20.7 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=9 ttl=54 time=20.3 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=10 ttl=54 time=24.2 ms 10 seconds elapsed instead of a year #### $ ./6.fork.pl relevant processes with pstree command: 6.fork.pl,6800 -w ./6.fork.pl |-6.fork.pl,6801 -w ./6.fork.pl | `-sh,6803 -c ping www.google.com >5.fork.txt | `-ping,6804 www.google.com `-pstree,6802 -Apal 6800 6801 terminated PING www.google.com(sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004)) 56 data bytes 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=1 ttl=54 time=141 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=2 ttl=54 time=17.8 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=3 ttl=54 time=33.0 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=4 ttl=54 time=31.7 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=5 ttl=54 time=28.0 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=6 ttl=54 time=34.9 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=7 ttl=54 time=25.0 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=8 ttl=54 time=19.7 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=9 ttl=54 time=18.2 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=10 ttl=54 time=39.5 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=144 ttl=54 time=18.5 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=145 ttl=54 time=271 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=146 ttl=54 time=346 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=147 ttl=54 time=35.9 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=148 ttl=54 time=205 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=149 ttl=54 time=42.1 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=150 ttl=54 time=168 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=151 ttl=54 time=20.5 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=152 ttl=54 time=377 ms 10? <-ten seconds elapsed from forked process #### $ ./6.fork.pl relevant processes with pstree command: 6.fork.pl,6839 -w ./6.fork.pl |-6.fork.pl,6840 -w ./6.fork.pl | `-sh,6842 -c ping www.google.com >5.fork.txt | `-ping,6843 www.google.com `-pstree,6841 -Apal 6839 6840 terminated PING www.google.com(sea30s02-in-x04.1e100.net (2607:f8b0:400a:803::2004)) 56 data bytes 64 bytes from sea30s02-in-x04.1e100.net (2607:f8b0:400a:803::2004): icmp_seq=1 ttl=54 time=33.4 ms 64 bytes from sea30s02-in-x04.1e100.net (2607:f8b0:400a:803::2004): icmp_seq=4 ttl=54 time=36.3 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=460 ttl=54 time=123 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=463 ttl=54 time=37.0 ms 64 bytes from sea15s07-in-x04.1e100.net (2607:f8b0:400a:800::2004): icmp_seq=466 ttl=54 time=18.1 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=605 ttl=54 time=44.4 ms 64 bytes from sea15s11-in-x04.1e100.net (2607:f8b0:400a:808::2004): icmp_seq=608 ttl=54 time=31.3 ms 10 ? <-ten seconds elapsed from forked process #### $ ping: sendmsg: Network is unreachable ping: sendmsg: Network is unreachable ping: sendmsg: Network is unreachable ... #### $ ping -c 3 www.google.com PING www.google.com(sea15s12-in-x04.1e100.net (2607:f8b0:400a:809::2004)) 56 data bytes 64 bytes from sea15s12-in-x04.1e100.net (2607:f8b0:400a:809::2004): icmp_seq=1 ttl=54 time=17.0 ms 64 bytes from sea15s12-in-x04.1e100.net (2607:f8b0:400a:809::2004): icmp_seq=2 ttl=54 time=21.1 ms 64 bytes from sea15s12-in-x04.1e100.net (2607:f8b0:400a:809::2004): icmp_seq=3 ttl=54 time=19.0 ms --- www.google.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 17.096/19.092/21.126/1.649 ms #### #!/usr/bin/perl -w use 5.011; use Net::Ping; my $start = time; if ( fork() == 0 ) { # arm the alarm clock alarm(5); my @sites = qw/www.google.com www.merrillpjensen.com www.perlmonks.org/; for my $host (@sites) { my $p = Net::Ping->new(); print "$host is alive.\n" if $p->ping($host); $p->close(); } exit(0); } say "relevant processes with pstree command:"; system("pstree -Apal $$"); while ( ( my $pid = wait() ) != -1 ) { say "$pid terminated"; } #system("cat 7.fork.txt"); say time - $start, " ? seconds elapsed from forked process" __END__ #### relevant processes with pstree command: 7.fork.pl,27579 -w ./7.fork.pl |-7.fork.pl,27580 -w ./7.fork.pl `-pstree,27581 -Apal 27579 27580 terminated 5 ? seconds elapsed from forked process