wxProcess & wxExecute - how it works

968 views
Skip to first unread message

rossig

unread,
Jan 21, 2013, 4:46:20 PM1/21/13
to wx-u...@googlegroups.com
Hello, sorry if this question was made before, but I didn't find something similar.
Here's the problem, I need to execute 2 console commands, one is a linux command and the other one is a shel script (.sh) which use some fmpeg commands.

I execute the first correctly, but the second one isn't even executed.

The code is below, I appreciate any suggestion.
Thanks and regards

Rossig

   stringstream scomando << "mkdir /home/usuario/Xelestina/creadoporcodeblock";
 
   stting comando = scomando.str();

   process = new wxProcess(wxPROCESS_REDIRECT);         // Make a new Process, the sort with built-in redirection
   pid = wxExecute(wxString(comando.c_str(), wxConvLocal), wxEXEC_SYNC, process); // Try & run the command.  pid of 0 means failed

   if (pid < 0)
   {
        lblEstado->SetLabel(_("PROBLEMAS CARPETAS"));
        delete process;
        return;
   }

   delete process;

   lblEstado->SetLabel(_(""));
   lblEstado->SetLabel(_("CREO CARPETA"));

   string nom_video = "";
   string nom_vid_cod = "/home/usuario/Xelestina/vid_cod.avi";

   scomando.clear();
   scomando.str("");
   nom_video = "video2.avi";
   scomando << "./ffmpeg_codif.sh "

Vadim Zeitlin

unread,
Jan 22, 2013, 7:22:55 AM1/22/13
to wx-u...@googlegroups.com
On Mon, 21 Jan 2013 13:46:20 -0800 (PST) rossig wrote:

r> Hello, sorry if this question was made before, but I didn't find something
r> similar.
r> Here's the problem, I need to execute 2 console commands, one is a linux
r> command and the other one is a shel script (.sh) which use some fmpeg
r> commands.
r>
r> I execute the first correctly, but the second one isn't even executed.

First, you don't actually show any code executing the second command. If
you really don't have it, it's not really surprising that it's not
executed.

If you do have it and just omitted for whatever reason, a possible problem
is that your shell script is either not executable (check its mode) or
doesn't start with "#!/bin/sh" or similar line. In either case you could
use wxShell() to still run it but it should also work with wxExecute()
under Unix if both of the above conditions are satisfied.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

rossig

unread,
Jan 22, 2013, 5:12:47 PM1/22/13
to wx-u...@googlegroups.com


Hi, actually I cut the code, but there was an wxExecute in my code.

wxProcess *process = new wxProcess(wxPROCESS_REDIRECT); // by giving the process this frame, we are notified when it dies
 
int pid = int(wxExecute(processStr, wxEXEC_SYNC, process));
if (pid < 0)
// break execution program

// set a new processStr content

process = new wxProcess(wxPROCESS_REDIRECT); // by giving the process this frame, we are notified when it dies
 
 pid = int(wxExecute(processStr, wxEXEC_SYNC, process));


The second executes doesn't do anything, I checked with the CPU monitor , it hasn't the process running.

thanks, regards

rossig


 


rossig

unread,
Jan 22, 2013, 7:23:12 PM1/22/13
to wx-u...@googlegroups.com

What's wrong with this code? it does nothing, it seems it keep hangs, but it didn't create the folder.
The code below is at onClick button event.

    lblEstado->SetLabel(_("Procesando..."));


    wxProcess *process = new wxProcess(wxPROCESS_REDIRECT); // by giving the process this frame, we are notified when it dies

    long pid = wxExecute(wxT("mkdir /home/usuario/Xelestina"), wxEXEC_SYNC, process);
   
    if (pid < 0)
    {
        lblEstado->SetLabel(_("Problemas..."));
        delete process;
        return;
    }
  
Thanks, rossig



 


 


Vadim Zeitlin

unread,
Jan 23, 2013, 6:37:23 AM1/23/13
to wx-u...@googlegroups.com
On Tue, 22 Jan 2013 16:23:12 -0800 (PST) rossig wrote:

r> What's wrong with this code? it does nothing, it seems it keep hangs, but
r> it didn't create the folder.
r> The code below is at* onClick *button event.
r>
r> lblEstado->SetLabel(_("Procesando..."));
r>
r> wxProcess *process = new wxProcess(wxPROCESS_REDIRECT); // by giving
r> the process this frame, we are notified when it dies
r>
r> long pid = wxExecute(wxT("mkdir /home/usuario/Xelestina"), wxEXEC_SYNC,
r> process);
r>
r> if (pid < 0)
r> {
r> lblEstado->SetLabel(_("Problemas..."));
r> delete process;
r> return;
r> }

I don't see anything wrong with it. Does this command work for you in the
exec sample?
Reply all
Reply to author
Forward
0 new messages