/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to classes/aux/auxapplication.php

  • Committer: Suren A. Chilingaryan
  • Date: 2009-01-31 05:47:16 UTC
  • Revision ID: csa@dside.dyndns.org-20090131054716-jngbgoo8qyelv8dn
Demo implementation of KATRIN-run information

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class AUXApplication
 
4
{
 
5
    var $command;
 
6
 
 
7
    function __construct($command)
 
8
    {
 
9
        $this->command = $command;
 
10
    }
 
11
 
 
12
    function Run($args = array())
 
13
    {
 
14
        $spec = array(1 => array("pipe", "w"));
 
15
 
 
16
        $command = $this->command;
 
17
 
 
18
        foreach ($args as $arg) {
 
19
            $command .= " " . escapeshellcmd($arg);
 
20
        }
 
21
 
 
22
        $process = proc_open($command, $spec, $pipes);
 
23
 
 
24
        echo stream_get_contents($pipes[1]);
 
25
        fclose($pipes[1]);
 
26
 
 
27
        return proc_close($process);
 
28
    }
 
29
}
 
30
 
 
31
class AUXApplicationParameters
 
32
{
 
33
    var $command;
 
34
    var $parameters;
 
35
 
 
36
    function __construct($command)
 
37
    {
 
38
        $this->command = $command;
 
39
        $this->parameters = array();
 
40
    }
 
41
 
 
42
    function Run($args = array())
 
43
    {
 
44
        $spec = array(
 
45
            0 => array("pipe", "r"),
 
46
            1 => array("pipe", "w")
 
47
        );
 
48
 
 
49
        $command = $this->command;
 
50
 
 
51
        foreach ($args as $arg) {
 
52
            $command .= " " . escapeshellcmd($arg);
 
53
        }
 
54
        
 
55
        $process = proc_open($command, $spec, $pipes);
 
56
 
 
57
        foreach ($this->parameters as $name => $value) {
 
58
            fwrite($pipes[0], "$name::$value\n");
 
59
        }
 
60
        fclose($pipes[0]);
 
61
 
 
62
        echo stream_get_contents($pipes[1]);
 
63
        fclose($pipes[1]);
 
64
 
 
65
        return proc_close($process);
 
66
    }
 
67
 
 
68
    function AddParameter($name, $value)
 
69
    {
 
70
        $this->parameters[$name] = $value;
 
71
    }
 
72
 
 
73
    function ClearParameters()
 
74
    {
 
75
        $this->parameters = array();
 
76
    }
 
77
}
 
78
?>
 
 
b'\\ No newline at end of file'