]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. _execute_command_line: | |
7 | ||
8 | EXECUTE_COMMAND_LINE --- Execute a shell command | |
9 | ************************************************ | |
10 | ||
11 | .. index:: EXECUTE_COMMAND_LINE, system, system call, command line | |
12 | ||
13 | .. function:: EXECUTE_COMMAND_LINE(COMMAND, WAIT, EXITSTAT, CMDSTAT, CMDMSG) | |
14 | ||
15 | ``EXECUTE_COMMAND_LINE`` runs a shell command, synchronously or | |
16 | asynchronously. | |
17 | ||
18 | :param COMMAND: | |
19 | Shall be a default ``CHARACTER`` scalar. | |
20 | ||
21 | :param WAIT: | |
22 | (Optional) Shall be a default ``LOGICAL`` scalar. | |
23 | ||
24 | :param EXITSTAT: | |
25 | (Optional) Shall be an ``INTEGER`` of the | |
26 | default kind. | |
27 | ||
28 | :param CMDSTAT: | |
29 | (Optional) Shall be an ``INTEGER`` of the | |
30 | default kind. | |
31 | ||
32 | :param CMDMSG: | |
33 | (Optional) Shall be an ``CHARACTER`` scalar of the | |
34 | default kind. | |
35 | ||
36 | Standard: | |
37 | Fortran 2008 and later | |
38 | ||
39 | Class: | |
40 | Subroutine | |
41 | ||
42 | Syntax: | |
43 | .. code-block:: fortran | |
44 | ||
45 | CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ]) | |
46 | ||
47 | Example: | |
48 | .. code-block:: fortran | |
49 | ||
50 | program test_exec | |
51 | integer :: i | |
52 | ||
53 | call execute_command_line ("external_prog.exe", exitstat=i) | |
54 | print *, "Exit status of external_prog.exe was ", i | |
55 | ||
56 | call execute_command_line ("reindex_files.exe", wait=.false.) | |
57 | print *, "Now reindexing files in the background" | |
58 | ||
59 | end program test_exec | |
60 | ||
61 | Note: | |
62 | Because this intrinsic is implemented in terms of the ``system`` | |
63 | function call, its behavior with respect to signaling is processor | |
64 | dependent. In particular, on POSIX-compliant systems, the SIGINT and | |
65 | SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As | |
66 | such, if the parent process is terminated, the child process might not be | |
67 | terminated alongside. | |
68 | ||
69 | See also: | |
70 | :ref:`SYSTEM` |