programmazione:glib:catturare_output_comando
Catturare output comando con glib
Autore: Fabio Di Matteo
Ultima revisione: 31/07/2025 11:36
#include <glib.h> ... gchar* execute(gchar* cmd[]) { GError *error = NULL; gchar *output = NULL; // will contain command output gchar *errorMsg = 0; // will contain command output int exit_status = 0; g_spawn_sync(NULL, cmd, NULL, 0, NULL, NULL, &output, &errorMsg, &exit_status, &error); if (exit_status!=0) { g_print(" Errore: %s\n",error->message); g_error_free (error); if (strlen(errorMsg)!=0) { g_print("Errori: %s\n", errorMsg); return errorMsg; } } return output; }
programmazione/glib/catturare_output_comando.txt · Ultima modifica: 31/07/2025 11:37 da Fabio Di Matteo
