More on the EXEC function call [message #115396] |
Wed, 18 September 2013 17:59 |
starr
Messages: 30 Registered: May 2013
Karma: 0
|
Member |
|
|
Message-ID: <242@shell.UUCP>
Date: Tue, 12-Feb-85 01:03:46 EST
Article-I.D.: shell.242
Posted: Tue Feb 12 01:03:46 1985
Date-Received: Fri, 15-Feb-85 04:45:40 EST
Organization: Shell Development Co., P&CS Dept., Houston TX
Lines: 1
~r submit.02
|
|
|
Re: More on the EXEC function call [message #115403 is a reply to message #115396] |
Wed, 18 September 2013 17:59 |
jchapman
Messages: 40 Registered: September 2013
Karma: 0
|
Member |
|
|
Message-ID: <1275@watcgl.UUCP>
Date: Fri, 15-Feb-85 12:19:22 EST
Article-I.D.: watcgl.1275
Posted: Fri Feb 15 12:19:22 1985
Date-Received: Sat, 16-Feb-85 05:49:39 EST
References: <243@shell.UUCP>
Organization: U of Waterloo, Ontario
Lines: 62
> I am writing a program which must be able to execute another
> program from within my program, based upon a user supplied
> command.
>
> Using DOS function 4B works fine. For a while, I was merely
> using it to invoke a second copy of COMMAND.COM (god, I wish
> MicroSoft had seperated the code & data segments so this wasn't
> necessary). Anyhow, if I use function 4B to invoke a second
> COMMAND.COM, my specified command can use redirection.
>
> BUT, I decided I would try to eliminate the overhead of loading
> COMMAND.COM when a program was being invoked. Well, suprise! If
> you run function 4B to load a program which has redirection on
> the command line, it doesn't work!
>
> Could someone please tell me how I can inform DOS apriori that I
> wish all standard output (or input) to be redirected? Is IOCTL the
> way to go? If so, how is it done?
>
> Any help would be much appreciated. Thanks.
>
> Bob Starr @ Shell Development
I too was wanting to redirect io for an invoked command; this
was mentioned in only one place in my MS-DOS documentation
something to the effect "you can change the definition of
stdin & stdout and then invoke a program, this is extremely
powerful" and then no mention anywhere of how to do it.
Anyway after a while I figured it out (I think - I have only
done minor testing but it seems to work the way you would
expect); I'm doing this from memory so I can't give you the
function numbers but they are in the doc. Sooo, if you want
to redirect stdin to file XXX do something like the following:
1. open a file handle to XXX
2. do a force duplicate file handle (force duplicate not
just duplicate file handle), setting cx=1 just before.
For this call cx is the number of the new file handle
to be the duplicate.
3. close the original file handle to XXX
4. EXEC your program.
The mapping of handles to devices seems to be:
Handle Device/File
1 stdin
2 stdout
3 auxin
4 auxout
5 stdlst
Some points to note:
1. this requires a free file handle to do plus the five
handles above so your config.sys FILES=n should
have n=6+number of other simultaneously open files
2. this affects not only i/o from the handles 1-5 but the
device specific function calls to con:,prn: etc (functions
1-9).
Hope this is what you wanted!
John Chapman
...!watmath!watcgl!jchapman
|
|
|
Re: More on the EXEC function call [message #115404 is a reply to message #115396] |
Wed, 18 September 2013 17:59 |
jchapman
Messages: 40 Registered: September 2013
Karma: 0
|
Member |
|
|
Message-ID: <1276@watcgl.UUCP>
Date: Fri, 15-Feb-85 12:24:22 EST
Article-I.D.: watcgl.1276
Posted: Fri Feb 15 12:24:22 1985
Date-Received: Sat, 16-Feb-85 05:49:53 EST
References: <243@shell.UUCP>
Organization: U of Waterloo, Ontario
Lines: 9
a p.s. to my previous followup
It sounds like you are expecting msdos to parse the command
line which you pass to it - it doesn't, the only use is to
put the image of the line where the program being invoked
expects to find it (80h in the program segment), that is
why you also have to explicitly give the name of the program
to be executed as well.
|
|
|
Re: More on the EXEC function call [message #115413 is a reply to message #115396] |
Wed, 18 September 2013 17:59 |
roy
Messages: 59 Registered: May 2013
Karma: 0
|
Member |
|
|
Message-ID: <132@gitpyr.UUCP>
Date: Fri, 15-Feb-85 10:21:43 EST
Article-I.D.: gitpyr.132
Posted: Fri Feb 15 10:21:43 1985
Date-Received: Sun, 17-Feb-85 04:34:15 EST
References: <243@shell.UUCP>
Organization: Georgia Institute of Technology, Atlanta, GA
Lines: 18
> Could someone please tell me how I can inform DOS apriori that I
> wish all standard output (or input) to be redirected? Is IOCTL the
> way to go? If so, how is it done?
To redirect stdin, you close handle 0 (which is standard input),
and then open the file you want to be stdin. That file is allocated
the first free file handle (in this case 0 since we just freed it),
and voila! stdin is redirected. Likewise for stdout and handle 1.
Then you load and exec your program. To get stdin/stdout back to
the console, you can dup handle 2 (stderr) unless you have changed
it also (in which case you can open "con:").
--
Roy J. Mongiovi. Office of Computing Services. User Services.
Georgia Institute of Technology. Atlanta GA 30332. (404) 894-6163
...!{akgua, allegra, amd, hplabs, ihnp4, masscomp, ut-ngp}!gatech!gitpyr!roy
Who me? I'm not even a REAL modo, I'm only a quasi-modo.
|
|
|
Re: More on the EXEC function call [message #115439 is a reply to message #115396] |
Wed, 18 September 2013 17:59 |
cjn
Messages: 25 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
Message-ID: <1058@druxm.UUCP>
Date: Mon, 18-Feb-85 21:46:41 EST
Article-I.D.: druxm.1058
Posted: Mon Feb 18 21:46:41 1985
Date-Received: Thu, 21-Feb-85 07:07:54 EST
References: <243@shell.UUCP>, <1276@watcgl.UUCP>
Organization: AT&T Information Systems Laboratories, Denver
Lines: 13
John was almost right, the standard MsDos file handles are:
0 .... Std input device
1 .... Std output device
2 .... Std error output device
3 .... Std auxiliary device (typically com port)
4 .... Std printer device (lpt1)
Chris Netter
AT&T Information Systems
Denver, Co
druxm!cjn
|
|
|