Last active
June 20, 2023 14:08
-
-
Save ppsdatta/c7a3b25efb8a2e64fe81bef3443f5f37 to your computer and use it in GitHub Desktop.
Comm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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