© 2023 PodTECH IO
All rights reserved.

Get in Touch

Perl

send: Cannot determine peer address

Looking into IO::Socket at http://search.cpan.org/src/GBARR/IO-1.2301/IO/Socket.pm reveals: [perl] sub send { @_ >= 2 && @_ <= 4 or croak ‘usage: $sock->send(BUF, [FLAGS, [TO]] +)’; my $sock = $_[0]; my $flags = $_[2] || 0; my $peer = $_[3] || $sock->peername; croak ‘send: Cannot determine peer address’ unless($peer); [/perl] So you have to take care that […]

Perl

Perl – Is a value decimal, real or a string?

Perl – Is a value decimal, real or a string? To validate if a number is a number using regex. [perl] $number = “12.3”; if ($number =~ /\D/) { print “has nondigits\n” } if ($number =~ /^\d+$/) { print “is a whole number\n” } if ($number =~ /^-?\d+$/) { print “is an integer\n” } if […]

Perl

Perl – Basic Fork Example

#!/usr/local/bin/perl   use strict; use warnings;   print “Starting main program\n”; my @childs;   for ( my $count = 1; $count <= 10; $count++) {         my $pid = fork();         if ($pid) {         # parent         #print “pid is $pid, parent $$\n”;         push(@childs, $pid);         } elsif ($pid == 0) {                 # child                 sub1($count);                 exit 0;         } else […]

PHP

PHP – Basic Fork Example

<?   print “Starting main program\n”; $childs = array();   for ( $count = 1; $count <= 10; $count++) {         $pid = pcntl_fork();         if ( $pid == -1 ) {                 // Fork failed                           echo “Fork failed\n”;                 exit(1);         } else if ( $pid ) {                 # parent                 #print “pid is $pid, parent $$\n”;                 array_push($childs, $pid);         } […]

Programming UNIX

UNIX – Fork Explained

Mr. Peabody Explains fork() Introduction How Windows Does It How Unix Does It So Why Do People Want the Unix Way? How does it work in Perl? Introduction UNIX – Fork Explained Say, Mr Peabody. I was just reading through the Perl 5.6 release notes and noticed that a new function called fork() is now […]

UNIX

Ubuntu – Which Process is Using a port?

Ubuntu – Which Process is Using a port? 1- Find what application/process is using the pro, type: sudo netstat -lpn |grep :8080 and press Enter. You will get an output similar to this one tcp6       0      0 :::8080                 :::*                    LISTEN      6782/java 2- I have got the process Id, which is 6782, now this is the […]

Security UNIX

Heart Bleed – Exploit Example Code

Heart Bleed – Exploit Example Code If you need to test your server for the vulnerability, here is a simple Python script… [python] #!/usr/bin/python import sys import struct import socket import time import select import re from optparse import OptionParser options = OptionParser(usage=’%prog server [options]’, description=’Test for SSL heartbeat vulnerability (CVE-2014-0160)’) options.add_option(‘-p’, ‘–port’, type=’int’, default=443, […]

Perl

Perl – Compare Array Contents when length is identical and order matches

Perl – Compare Array Contents when length is identical and order matches Comparing arrays side by side. Do they match or dont they? @a=(1,0,1,0,0); @b=(0,0,1,0,0); NO! @arr1=(0,1,1,1,1,1,0,1); @arr2=(0,1,1,1,1,1,0,1); use Algorithm::Diff qw( LCS_length); my $arr_count1 = @arr1; my $arr_count2 = @arr2; if($arr_count1 != $arr_count2) { print “NOMATCH\n”; ## NO MATCH } else { $count = LCS_length […]