Skip to content

Instantly share code, notes, and snippets.

@ppsdatta
Last active June 20, 2023 14:08
Show Gist options
  • Save ppsdatta/c7a3b25efb8a2e64fe81bef3443f5f37 to your computer and use it in GitHub Desktop.
Save ppsdatta/c7a3b25efb8a2e64fe81bef3443f5f37 to your computer and use it in GitHub Desktop.
Comm
use strict;
use warnings;
use IO::Socket;
sub handle {
my $c = shift;
my $command = <$c>;
$command = "" unless $command;
chomp $command;
print "COMMAND] $command\n";
if ($command =~ /^link: (.*)$/) {
print "\tOPEN LINK] $1\n";
system "open $1";
}
print $c "OK\n";
close $c;
}
my $server = IO::Socket::INET->new(
LocalPort => 8000,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 10
);
my $out = `ifconfig | grep 192.168*`;
print $out, "\n";
while (my $client = $server->accept) {
handle $client;
}
close $server;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment