From f85e3772f998e0c44869b42db16c6bc5f4f63b6b Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 31 May 2016 19:17:46 +0200 Subject: [PATCH] api: sample command line api call in perl tx to lilyth for the idea (works on cpuminer, sgminer and cgminer too) --- api/summary.pl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 api/summary.pl diff --git a/api/summary.pl b/api/summary.pl new file mode 100755 index 0000000..e04a8ec --- /dev/null +++ b/api/summary.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +# sample script to query ccminer API + +my $command = "summary|"; + +use Socket; +use IO::Socket::INET; + +my $sock = new IO::Socket::INET ( + PeerAddr => '127.0.0.1', + PeerPort => 4068, + Proto => 'tcp', + ReuseAddr => 1, + Timeout => 10, +); + +if ($sock) { + + print $sock $command; + my $res = ""; + + while(<$sock>) { + $res .= $_; + } + + close($sock); + print("$res\n"); + +} else { + + print("ccminer socket failed\n"); + +}