forked from AlphaKnot/PlanItTime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommand.cpp
47 lines (34 loc) · 837 Bytes
/
Command.cpp
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
/**
* @author Ishaan Kumar; 251069961.
*/
#include "Command.h"
using namespace boost::process;
using namespace std;
//Constructor
Command::Command() {
filename = "/home/pi/Desktop/dial.py";
command = "python ";
outputComm = "";
command += filename;
}
string Command::getOutput() {
return outputComm;
}
/**
* @brief: It takes in an argument in the form of string and runs in through command line and returns the necessary
* outputs
**/
void Command::execute(string command) {
try {
child c(command, (std_out) > pipe_stream);
string line;
while (pipe_stream && std::getline(pipe_stream, line) && !line.empty())
outputComm += line;
c.wait();
}
catch (const std::exception &e) {
outputComm = "100";
}
}
Command::~Command(){
}