Welcome, Guest. Please login or register.

Author Topic: Execute, System or RunCommand ?  (Read 2678 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Execute, System or RunCommand ?
« on: June 11, 2005, 01:00:49 PM »
Hi. Seems that I'm hijacking this forum all the way:-D

Here's the deal, I'm using CreateNewProc to set up a separate process that will handle an input buffer asychronously for better efficiency and multitasking. For now I haven't done any GUI so I was hoping to use some printf's from the new created process to be sure things are going ok. The darn thing refuses to printf to the Shell eventhough the Execute function I have inside it prints the output of a command correctly.
The code I'm using to start it is:

Code: [Select]
BOOL LoadBufferProcess (BOOL Ini_or_CleanUp)
 {
 BPTR bufferprocessSeglist = 0;
 static struct TagItem TagsforCreateNewProc[6];
 
 if (Ini_or_CleanUp)
   {if (!(bufferprocessSeglist = LoadSeg ("MDBuffer")))
     {printf("Couldn't load MD Buffer..\n");
      return (FALSE);}
    TagsforCreateNewProc[0].ti_Tag = NP_Seglist;
    TagsforCreateNewProc[0].ti_Data = bufferprocessSeglist;
    TagsforCreateNewProc[1].ti_Tag = NP_Name;
    TagsforCreateNewProc[1].ti_Data = (ULONG)"MDBuffer";
    TagsforCreateNewProc[2].ti_Tag = NP_Cli;
    TagsforCreateNewProc[2].ti_Data = TRUE;
  /*TagsforCreateNewProc[3].ti_Tag = NP_Output;*/
  /*TagsforCreateNewProc[3].ti_Data = Output();*/
    TagsforCreateNewProc[3].ti_Tag = NP_CloseOutput;
    TagsforCreateNewProc[3].ti_Data = FALSE;
    TagsforCreateNewProc[4].ti_Tag = TAG_DONE;
    if(!CreateNewProc (TagsforCreateNewProc))
      printf("Couldn't create MDBuffer Process..\n");
    else
      {printf ("MDBuffer now active...\n");
       return (TRUE);
      }
    }
 return (FALSE);
 }



Here another one:
I'm a bit undecided as to wheter go for Execute() or RunCommand() or even System().
From the DevCD: the first one doesn't give any comnmand output. System is similar but doesn't read input from a filehandle and Creates a new process (does the first one also does that?)
And finally there's RunCommand wich uses the current process to run the command, but the docs say nothing about output.
The last 2 have the big advantage of returning the commands return value so error checking can be done.

Questions:
- What's the point in having the command executed with CreateNewProc if it only returns when it finishes anyway ?

- I'd go for RunCommand but how can I know or define how it's output is handled ? I suppose since it uses the current process it uses it's output window, console process, etc?

- Final is the Cli structure really necessary (on the above code) ?

\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Dammit, I must refrain from posting so quickly, I have some commented lines on the code and that's the prblem :oops:

But the last buch of questions still holds... :-)
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
@Piru
Thx :-)
\\"We made Amiga, they {bleep}ed it up\\"