-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdctl-dev.php
More file actions
63 lines (51 loc) · 1.01 KB
/
Copy pathdctl-dev.php
File metadata and controls
63 lines (51 loc) · 1.01 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
require_once(dirname(__FILE__) . '/lib/dctl.inc.php');
set_time_limit(0);
$HOST = null;
$PORT = 1626;
$TIMEOUT = 5*60;
if(!sizeof($argv))
throw new Exception("Task argument is not set");
$task = null;
$task_args = array();
foreach(dctl_parse_argv($argv) as $key => $value)
{
if(is_numeric($key))
{
if($key > 0)
{
if($key == 1)
$task = $value;
else
$task_args[] = $value;
}
}
else
{
switch($key)
{
case 'h':
case 'host':
$HOST = $value;
break;
case 'p':
case 'port':
$PORT = $value;
break;
case 'timeout':
$TIMEOUT = $value;
break;
}
}
}
if(!$task)
throw new Exception("Task name is not set");
if(is_null($HOST))
$HOST = dctl_autoguess_host();
$stdin = dctl_read_from_stdin();
//put stdin as a first arg
if($stdin)
array_unshift($task_args, $stdin);
$TASK = new dctlTask($task, $task_args);
$DCTL = new DCTL($PORT, $HOST, $TIMEOUT);
exit($DCTL->run($task, $task_args));