2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: Execute a CLI command
9 #include <aros/debug.h>
10 #include <dos/dosextens.h>
11 #include <utility/tagitem.h>
13 #include "dos_intern.h"
15 /*****************************************************************************
18 #include <proto/dos.h>
20 AROS_LH3(BOOL
, Execute
,
23 AROS_LHA(CONST_STRPTR
, string
, D1
),
24 AROS_LHA(BPTR
, input
, D2
),
25 AROS_LHA(BPTR
, output
, D3
),
28 struct DosLibrary
*, DOSBase
, 37, Dos
)
31 Execute a CLI command specified in 'string'. This string may contain
32 features you may use on the shell commandline like redirection using >,
33 < or >>. Execute() doesn't return until the command(s) that should be
34 executed are finished.
36 If 'input' is not NULL, more commands will be read from this stream
37 until end of file is reached. 'output' will be used as the output stream
38 of the commands (if output is not redirected). If 'output' is NULL the
39 current window is used for output -- note that programs run from the
40 Workbench doesn't normally have a current window.
43 string - pointer to a NULL-terminated string with commands
45 input - stream to use as input (may be NULL)
46 output - stream to use as output (may be NULL)
49 Boolean telling whether Execute() could find and start the specified
50 command(s). (This is NOT the return code of the command(s).)
63 To get the right result, the function ExecCommand() (used by both
64 Execute() and SystemTagList()) uses NP_Synchronous to wait for the
65 commands to finish. This is not the way AmigaOS does it as
66 NP_Synchronous is not implemented (but defined).
68 *****************************************************************************/
73 struct TagItem tags
[] =
75 { SYS_Background
, TRUE
},
76 { SYS_Asynch
, FALSE
},
77 { SYS_Input
, (IPTR
)input
},
78 { SYS_Output
, (IPTR
)output
},
79 { SYS_Error
, (IPTR
)NULL
},
83 D(bug("[Execute] input = %p, output = %p, cmd = \"%s\"\n", input
, output
, string
));
85 /* Check for the special cases where we want a new
88 if ((!string
|| string
[0] == 0) && IsInteractive(input
) && output
== BNULL
)
89 tags
[0].ti_Data
= FALSE
;
91 if ((!string
|| string
[0] == 0) && input
== BNULL
&& output
== BNULL
)
92 string
= "Run NewShell";
94 result
= SystemTagList(string
, tags
);