john13@garfield.MUN.EDU (John Russell) (11/13/88)
In reading the description of Execute() in the AmigaDOS Developer's Manual, the bit about the filehandles you pass to it isn't clear. If I want to do the equivalent of "foo >nil: <nil:" I'm opening a filehandle nilfh to NIL: and doing an Execute("foo", nilfh, nilfh). I know you can put the redirection in the string itself, but the string to be executed is variable. 1. Can I use the same MODE_NEWFILE handle for both input and output handles? 2. Will the handles be closed when Execute returns or can I leave them open and re-use them for each call? John -- "Families of Murder Victims bring Human Face to Court Proceedings" -- Gets my vote as most poorly-worded headline of the year
peter@sugar.uu.net (Peter da Silva) (11/14/88)
In article <4997@garfield.MUN.EDU>, john13@garfield.MUN.EDU (John Russell) writes: > In reading the description of Execute() in the AmigaDOS Developer's Manual, > the bit about the filehandles you pass to it isn't clear. That's certainly true. I'm still not sure when you even want to provide them. -- Peter da Silva `-_-' peter@sugar.uu.net Have you hugged U your wolf today? Disclaimer: My typos are my own damn business.
rap@ardent.UUCP (Rob Peck) (11/15/88)
In article <4997@garfield.MUN.EDU>, john13@garfield.MUN.EDU (John Russell) writes: > 1. Can I use the same MODE_NEWFILE handle for both input and output handles? As I recall, yes. struct FileHandle *nilfh, *Open(); /* (I dont have my manuals handy) */ nilfh = Open("nil:",MODE_NEWFILE); success = Execute("foo",nilfh,nilfh); Close(nilfh); > 2. Will Execute close the file handles when it finishes? NO. It USES them, and has no idea where they came from. In creating the original version of RUNBACKGROUND, I did an extensive analysis of what happens when you substitute one or both of the file handles in Execute instead of using 0,0. I will try to locate that analysis and post it. Rob Peck
dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) (11/17/88)
:In article <4997@garfield.MUN.EDU>, john13@garfield.MUN.EDU (John Russell) writes:
:> In reading the description of Execute() in the AmigaDOS Developer's Manual,
:> the bit about the filehandles you pass to it isn't clear.
:
:That's certainly true. I'm still not sure when you even want to provide them.
:--
: Peter da Silva `-_-' peter@sugar.uu.net
Lezee, Execute("cli-command", infh, outfh);
Essentially, if INFH is non-null, this points to a stream which is
interpreted by the CLI as commands after the "cli-command" is run. I.E. it
is NOT the input-redirection for the command you are trying to run, but a
CLI script.
outfh, on the otherhand, *is* the output redirection of the command
you are trying to run.
And since you are giving it a cli-command, you can include redirection
within the command string itself, thus normally I do this:
Execute("somecommand <infile >outfile", NULL, NULL);
-Matt