7
7
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
8
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
10
Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
10
Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
11
11
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
12
Leonhard Wimmer <leo@mediatomb.cc>
24
24
version 2 along with MediaTomb; if not, write to the Free Software
25
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
27
$Id: process.cc 1698 2008-02-23 20:48:30Z lww $
27
$Id: process.cc 2010 2009-01-11 19:10:43Z lww $
30
30
/// \file process.cc
64
64
Ref<ConfigManager> cfg = ConfigManager::getInstance();
65
65
String input_file = tempName(cfg->getOption(CFG_SERVER_TMPDIR), temp_in);
66
fd = open(input_file.c_str(), O_RDWR);
67
int ret = write(fd, input.c_str(), input.length());
66
fd = open(input_file.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
69
log_debug("Failed to open input file %s: %s\n", input_file.c_str(),
71
throw _Exception(_("Failed to open input file ") + input_file +_(" ") +
74
ssize_t ret = write(fd, input.c_str(), input.length());
76
if (ret < input.length())
79
log_debug("Failed to write to %s: %s\n", input.c_str(),
81
throw _Exception(_("Failed to write to ") + input + ": " +
70
85
/* touching output file */
71
86
String output_file = tempName(cfg->getOption(CFG_SERVER_TMPDIR), temp_out);
72
fd = open(output_file.c_str(), O_RDWR);
87
fd = open(output_file.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
90
log_debug("Failed to open output file %s: %s\n", output_file.c_str(),
92
throw _Exception(_("Failed to open output file ")+ input_file +_(" ") +
75
97
/* executing script */
76
String command = prog + " " + param + " < " + input_file +
98
String command = prog + " " + param + " < " + input_file +
78
100
log_debug("running %s\n", command.c_str());
79
ret = system(command.c_str());
101
int sysret = system(command.c_str());
104
log_debug("Failed to execute: %s\n", command.c_str());
105
throw _Exception(_("Failed to execute: ") + command);
81
108
/* reading output file */
82
109
file = fopen(output_file.c_str(), "r");
112
log_debug("Could not open output file %s: %s\n", output_file.c_str(),
114
throw _Exception(_("Failed to open output file ")+output_file +_(" ") +
83
117
Ref<StringBuffer> output(new StringBuffer());