-
Notifications
You must be signed in to change notification settings - Fork 169
/
Copy pathThriftTester.php
36 lines (35 loc) · 932 Bytes
/
ThriftTester.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/php -q
<?php
$GLOBALS['THRIFT_ROOT'] = __DIR__ . "/libs/";
include_once $GLOBALS['THRIFT_ROOT'] . 'packages/Exadoop/Exadoop.php';
include_once $GLOBALS['THRIFT_ROOT'] . 'transport/TSocket.php';
include_once $GLOBALS['THRIFT_ROOT'] . 'transport/TTransport.php';
include_once $GLOBALS['THRIFT_ROOT'] . 'protocol/TBinaryProtocol.php';
if($argc < 3)
{
die("Usage: \nTester.php \"remote_ip:port\" \"command\"\n");
}
else
{
$ip = $argv[1];
$command = $argv[2];
$sock = explode(":", $ip);
$socket = new TSocket($sock[0], $sock[1]);
$socket->setSendTimeout(30000);
$socket->setRecvTimeout(30000);
$transport = new TBufferedTransport($socket);
$protocol = new TBinaryProtocol($transport);
$ehm = new ExadoopClient($protocol);
try
{
$transport->open();
$str = $ehm->RunCommand($command);
$transport->close();
}
catch(Exception $e)
{
$str = 'Caught exception: '. $e->getMessage(). "\n";
}
echo $str;
}
?>