Back to index

texmacs  1.0.7.15
unix_sys_utils.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : unix_sys_utils.cpp
00004 * DESCRIPTION: external command handling
00005 * COPYRIGHT  : (C) 2009  David MICHEL
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "unix_sys_utils.hpp"
00013 #include "file.hpp"
00014 #include <stdlib.h>
00015 
00016 int
00017 unix_system (string s) {
00018   char* _s = as_charp (s * " > /dev/null 2>&1");
00019   int ret = system (_s);
00020   tm_delete_array (_s);  
00021   return ret;
00022 }
00023 
00024 int
00025 unix_system (string cmd, string& result) {
00026   url temp= url_temp ();
00027   string temp_s= escape_sh (concretize (temp));
00028   char* _cmd = as_charp (cmd * " > " * temp_s * " 2>&1");
00029   int ret = system (_cmd);
00030   tm_delete_array (_cmd);
00031   bool flag= load_string (temp, result, false);
00032   remove (temp);
00033   if (flag) result= "";
00034   return ret;
00035 }
00036