* Spawn : Get the output of the called program @ 2005-04-06 10:21 Jean-Baptiste CAMPESATO 2005-04-06 10:52 ` Jean-Baptiste CAMPESATO ` (4 more replies) 0 siblings, 5 replies; 12+ messages in thread From: Jean-Baptiste CAMPESATO @ 2005-04-06 10:21 UTC (permalink / raw) Hello, I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but i wannt to get the output fo this program. Do you know how can i get the output with Spawn, or another function/procedure to do that ? Thanks ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 10:21 Spawn : Get the output of the called program Jean-Baptiste CAMPESATO @ 2005-04-06 10:52 ` Jean-Baptiste CAMPESATO 2005-04-06 11:15 ` Pascal Obry 2005-04-06 13:36 ` Martin Krischik 2005-04-06 13:34 ` Martin Krischik ` (3 subsequent siblings) 4 siblings, 2 replies; 12+ messages in thread From: Jean-Baptiste CAMPESATO @ 2005-04-06 10:52 UTC (permalink / raw) Le Wed, 06 Apr 2005 12:21:14 +0200, Jean-Baptiste CAMPESATO a ᅵcritᅵ: > Hello, > I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but > i wannt to get the output fo this program. > Do you know how can i get the output with Spawn, or another > function/procedure to do that ? > Thanks ReHello, I want to do that to create a "CGI Executer". I want to set the Environement for the called CGI Program, execute this program and get the output of this program. Somebody have an example for me please ? Thanks. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 10:52 ` Jean-Baptiste CAMPESATO @ 2005-04-06 11:15 ` Pascal Obry 2005-04-06 11:24 ` Jean-Baptiste CAMPESATO 2005-04-06 13:36 ` Martin Krischik 1 sibling, 1 reply; 12+ messages in thread From: Pascal Obry @ 2005-04-06 11:15 UTC (permalink / raw) Jean-Baptiste CAMPESATO <camje_lemon@a2lf.org> writes: > ReHello, > I want to do that to create a "CGI Executer". GNAT.Expects. But are you really trying to build CGI ? This is an obsolete framework for Web developpement, see AWS for something more up-to-date. Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.net --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 11:15 ` Pascal Obry @ 2005-04-06 11:24 ` Jean-Baptiste CAMPESATO 0 siblings, 0 replies; 12+ messages in thread From: Jean-Baptiste CAMPESATO @ 2005-04-06 11:24 UTC (permalink / raw) Le Wed, 06 Apr 2005 13:15:04 +0200, Pascal Obry a ᅵcritᅵ: > > Jean-Baptiste CAMPESATO <camje_lemon@a2lf.org> writes: > >> ReHello, >> I want to do that to create a "CGI Executer". > > GNAT.Expects. > > But are you really trying to build CGI ? This is an obsolete framework for Web > developpement, see AWS for something more up-to-date. > > Pascal. thanks for Expect. Yes i want to use a CGI Executer, i want to create a Ada Very Light Http Daemon :p. Without using AWS, for a personal exercice. Thanks. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 10:52 ` Jean-Baptiste CAMPESATO 2005-04-06 11:15 ` Pascal Obry @ 2005-04-06 13:36 ` Martin Krischik 1 sibling, 0 replies; 12+ messages in thread From: Martin Krischik @ 2005-04-06 13:36 UTC (permalink / raw) Jean-Baptiste CAMPESATO wrote: > Le Wed, 06 Apr 2005 12:21:14 +0200, Jean-Baptiste CAMPESATO a ᅵcritᅵ: > >> Hello, >> I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but >> i wannt to get the output fo this program. >> Do you know how can i get the output with Spawn, or another >> function/procedure to do that ? >> Thanks > > ReHello, > I want to do that to create a "CGI Executer". > I want to set the Environement for the called CGI Program, execute this > program and get the output of this program. > Somebody have an example for me please ? As I said AdaCL (adacl.sf.net). However, AdaCL also got a complete CGI framework - no need to write your own. Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 10:21 Spawn : Get the output of the called program Jean-Baptiste CAMPESATO 2005-04-06 10:52 ` Jean-Baptiste CAMPESATO @ 2005-04-06 13:34 ` Martin Krischik 2005-04-06 14:09 ` Marc A. Criley ` (2 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: Martin Krischik @ 2005-04-06 13:34 UTC (permalink / raw) Jean-Baptiste CAMPESATO wrote: > Hello, > I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but > i wannt to get the output fo this program. No you need a special library which attaches pipes to stdin and stdout. > Do you know how can i get the output with Spawn, or another > function/procedure to do that ? AdaCL (adacl.sf.net) has got a package (AdaCL.OS.Command) which can do exactly that. Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 10:21 Spawn : Get the output of the called program Jean-Baptiste CAMPESATO 2005-04-06 10:52 ` Jean-Baptiste CAMPESATO 2005-04-06 13:34 ` Martin Krischik @ 2005-04-06 14:09 ` Marc A. Criley 2005-04-06 14:43 ` Jean-Baptiste CAMPESATO 2005-04-12 9:28 ` Duncan Sands 4 siblings, 0 replies; 12+ messages in thread From: Marc A. Criley @ 2005-04-06 14:09 UTC (permalink / raw) Jean-Baptiste CAMPESATO wrote: > Hello, > I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but > i wannt to get the output fo this program. > Do you know how can i get the output with Spawn, or another > function/procedure to do that ? > Thanks Jim Rogers' "Pipes" has long been my "go to" package whenever I need to spawn a program and capture its output for post-processing: http://www.adapower.com/index.php?Command=Class&ClassID=Bindings&CID=181 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 10:21 Spawn : Get the output of the called program Jean-Baptiste CAMPESATO ` (2 preceding siblings ...) 2005-04-06 14:09 ` Marc A. Criley @ 2005-04-06 14:43 ` Jean-Baptiste CAMPESATO 2005-04-06 15:13 ` Dmitry A. Kazakov 2005-04-12 9:28 ` Duncan Sands 4 siblings, 1 reply; 12+ messages in thread From: Jean-Baptiste CAMPESATO @ 2005-04-06 14:43 UTC (permalink / raw) Le Wed, 06 Apr 2005 12:21:14 +0200, Jean-Baptiste CAMPESATO a ᅵcritᅵ: > Hello, > I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but > i wannt to get the output fo this program. > Do you know how can i get the output with Spawn, or another > function/procedure to do that ? > Thanks Thanks everybody :). I will read http://adacl.sourceforge.net/ and a doc about pipes. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 14:43 ` Jean-Baptiste CAMPESATO @ 2005-04-06 15:13 ` Dmitry A. Kazakov 2005-04-06 17:08 ` Martin Krischik 0 siblings, 1 reply; 12+ messages in thread From: Dmitry A. Kazakov @ 2005-04-06 15:13 UTC (permalink / raw) On Wed, 06 Apr 2005 16:43:31 +0200, Jean-Baptiste CAMPESATO wrote: > Le Wed, 06 Apr 2005 12:21:14 +0200, Jean-Baptiste CAMPESATO a �crit�: > >> I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but >> i wannt to get the output fo this program. >> Do you know how can i get the output with Spawn, or another >> function/procedure to do that ? >> Thanks > > Thanks everybody :). > I will read http://adacl.sourceforge.net/ and a doc about pipes. I don't like the design of either library because many programs heavily use stderr. For them to make it useful one needs all three pipes. Further, the stderr pipe should be read out asynchronously from a parallel task. Otherwise, you are risking to fall into a deadlock if the pipe buffer size is limited, which is often the case. Therefore, you need two procedures: Spawn to invoke the program and Wait to wait for its completion. Then when you read from the stdout take care about End_Error. Normally after End_Error, you just call Wait. Also the procedure Wait should raise an exception if stderr was not empty. P.S. We have implemented it for Unix/Posix with no GNAT.OS_lib, but alas it is proprietary. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 15:13 ` Dmitry A. Kazakov @ 2005-04-06 17:08 ` Martin Krischik 2005-04-07 9:33 ` Dmitry A. Kazakov 0 siblings, 1 reply; 12+ messages in thread From: Martin Krischik @ 2005-04-06 17:08 UTC (permalink / raw) Dmitry A. Kazakov wrote: > On Wed, 06 Apr 2005 16:43:31 +0200, Jean-Baptiste CAMPESATO wrote: > >> Le Wed, 06 Apr 2005 12:21:14 +0200, Jean-Baptiste CAMPESATO a ᅵcritᅵ: >> >>> I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) >>> but i wannt to get the output fo this program. >>> Do you know how can i get the output with Spawn, or another >>> function/procedure to do that ? >>> Thanks >> >> Thanks everybody :). >> I will read http://adacl.sourceforge.net/ and a doc about pipes. > > I don't like the design of either library because many programs heavily > use stderr. For them to make it useful one needs all three pipes. Excuse me! I wrote AdaCL.OS.Command explicitly for that purpose - to attach to all three pipes: -- -- Attach a Text_IO file to the Standart Input of the process -- procedure Attach_In ( -- Object itself. This : in out Object'Class; -- Text IO to be attached File : in out Ada.Text_IO.File_Type); -- -- Attach a Text_IO file to the Standart Output of the process -- procedure Attach_Out ( -- Object itself. This : in out Object'Class; -- Text IO to be attached File : in out Ada.Text_IO.File_Type); -- -- Attach a Text_IO file to the Error Output of the process -- procedure Attach_Error ( -- Object itself. This : in out Object'Class; -- Text IO to be attached File : in out Ada.Text_IO.File_Type); > Further, > the stderr pipe should be read out asynchronously from a parallel task. And yes AdaCL.OS.Command has asynchronously execution as well: -- -- Execution Mode -- type Mode is ( -- Start Process syncronous. Sync, -- Start Process asyncronous. Async, -- Start Process asyncronous and redirect standart in and -- standart out. In_Out); > Otherwise, you are risking to fall into a deadlock if the pipe buffer size > is limited, which is often the case. Therefore, you need two procedures: > Spawn to invoke the program and Wait to wait for its completion. -- -- Wait for the end of the command - only for Async and In_Out -- procedure Wait ( -- Object itself. This : in out Object); I know that AdaCL is not perfect - but before you bash it you should at least pick some feature which really isn't there. Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 17:08 ` Martin Krischik @ 2005-04-07 9:33 ` Dmitry A. Kazakov 0 siblings, 0 replies; 12+ messages in thread From: Dmitry A. Kazakov @ 2005-04-07 9:33 UTC (permalink / raw) On Wed, 06 Apr 2005 19:08:07 +0200, Martin Krischik wrote: > Dmitry A. Kazakov wrote: > >> On Wed, 06 Apr 2005 16:43:31 +0200, Jean-Baptiste CAMPESATO wrote: >> >>> Le Wed, 06 Apr 2005 12:21:14 +0200, Jean-Baptiste CAMPESATO a �crit�: >>> >>>> I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) >>>> but i wannt to get the output fo this program. >>>> Do you know how can i get the output with Spawn, or another >>>> function/procedure to do that ? >>>> Thanks >>> >>> Thanks everybody :). >>> I will read http://adacl.sourceforge.net/ and a doc about pipes. >> >> I don't like the design of either library because many programs heavily >> use stderr. For them to make it useful one needs all three pipes. > > Excuse me! I wrote AdaCL.OS.Command explicitly for that purpose - to attach > to all three pipes: > > -- > -- Attach a Text_IO file to the Standart Input of the process > -- > procedure Attach_In ( > -- Object itself. > This : in out Object'Class; > -- Text IO to be attached > File : in out Ada.Text_IO.File_Type); > > -- > -- Attach a Text_IO file to the Standart Output of the process > -- > procedure Attach_Out ( > -- Object itself. > This : in out Object'Class; > -- Text IO to be attached > File : in out Ada.Text_IO.File_Type); > > -- > -- Attach a Text_IO file to the Error Output of the process > -- > procedure Attach_Error ( > -- Object itself. > This : in out Object'Class; > -- Text IO to be attached > File : in out Ada.Text_IO.File_Type); > >> Further, >> the stderr pipe should be read out asynchronously from a parallel task. > > And yes AdaCL.OS.Command has asynchronously execution as well: > > -- > -- Execution Mode > -- > type Mode > is ( > -- Start Process syncronous. > Sync, > -- Start Process asyncronous. > Async, > -- Start Process asyncronous and redirect standart in and > -- standart out. > In_Out); And which one need to be used for stdin + stdout + stderr? What has In_Out to do in the company of Sync/Async? Why the same object cannot be both Sync and Async? If it cannot, then why this is not mapped to types? If it can, why then there is one primitive operation for both modes?... >> Otherwise, you are risking to fall into a deadlock if the pipe buffer size >> is limited, which is often the case. Therefore, you need two procedures: >> Spawn to invoke the program and Wait to wait for its completion. > > -- > -- Wait for the end of the command - only for Async and In_Out > -- > procedure Wait ( > -- Object itself. > This : in out Object); > > I know that AdaCL is not perfect - but before you bash it you should at > least pick some feature which really isn't there. I didn't critiqued a lack of features, but the design. It is still too low level. After all, dup, dup2, fork, waitpid are also here... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Spawn : Get the output of the called program 2005-04-06 10:21 Spawn : Get the output of the called program Jean-Baptiste CAMPESATO ` (3 preceding siblings ...) 2005-04-06 14:43 ` Jean-Baptiste CAMPESATO @ 2005-04-12 9:28 ` Duncan Sands 4 siblings, 0 replies; 12+ messages in thread From: Duncan Sands @ 2005-04-12 9:28 UTC (permalink / raw) To: Jean-Baptiste CAMPESATO; +Cc: comp.lang.ada > I want to called a programm (like the Spawn Procedure in GNAT.OS_lib) but > i wannt to get the output fo this program. > Do you know how can i get the output with Spawn, or another > function/procedure to do that ? There's also something called "expect". Check out g-expect.ads. Ciao, D. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2005-04-12 9:28 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-04-06 10:21 Spawn : Get the output of the called program Jean-Baptiste CAMPESATO 2005-04-06 10:52 ` Jean-Baptiste CAMPESATO 2005-04-06 11:15 ` Pascal Obry 2005-04-06 11:24 ` Jean-Baptiste CAMPESATO 2005-04-06 13:36 ` Martin Krischik 2005-04-06 13:34 ` Martin Krischik 2005-04-06 14:09 ` Marc A. Criley 2005-04-06 14:43 ` Jean-Baptiste CAMPESATO 2005-04-06 15:13 ` Dmitry A. Kazakov 2005-04-06 17:08 ` Martin Krischik 2005-04-07 9:33 ` Dmitry A. Kazakov 2005-04-12 9:28 ` Duncan Sands
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox