[UP]


Manual Reference Pages  - get_command (3)

NAME

get_command(3f) - [FORTRAN:INTRINSIC:SYSTEM ENVIRONMENT] Get the entire command line

CONTENTS

Description
Syntax
Arguments
Return Value
Example
Standard
Class
See Also

DESCRIPTION

Retrieve the entire command line that was used to invoke the program.

SYNTAX

call get_command([command, length, status])

ARGUMENTS

COMMAND
  - (Optional) shall be of type CHARACTER and of default kind.
LENGTH - (Optional) Shall be of type INTEGER and of default kind.
STATUS - (Optional) Shall be of type INTEGER and of default kind.

RETURN VALUE

If COMMAND is present, stores the entire command line that was used to invoke the program in COMMAND. If LENGTH is present, it is assigned the length of the command line. If STATUS is present, it is assigned 0 upon success of the command, -1 if COMMAND is too short to store the command line, or a positive value in case of an error.

Note that what is typed on the command line is often processed by a shell. The shell often processes special characters and white space before passing it to the program. The processing can typically be turned off by turning off globbing or quoting the command line arguments with quote characters and/or changing the default field separators, but this should rarely be necessary.

EXAMPLE

Sample program:

   program demo_get_command
   implicit none
   integer                      :: COMMAND_LINE_LENGTH
   character(len=:),allocatable :: COMMAND_LINE

! get command line length call get_command(length=COMMAND_LINE_LENGTH)

! allocate string big enough to hold command line allocate(character(len=COMMAND_LINE_LENGTH) :: COMMAND_LINE)

! get command line as a string call get_command(command=COMMAND_LINE)

! JIC:: trim leading spaces just in case COMMAND_LINE=adjustl(COMMAND_LINE)

write(*,’(a)’)COMMAND_LINE

end program demo_get_command

Sample execution:

./test_get_command
  arguments on the command line to echo # using the bash shell
./test_get_command
 
./test_get_command arguments
  *><‘~[]!{}?"’| on the command line to echo

STANDARD

[[Fortran 2003]] and later

CLASS

Subroutine

SEE ALSO

[[get_command_argument]], [[command_argument_count]]


get_command (3) March 18, 2019
Generated by manServer 1.08 from 84b42581-42f3-4a3f-b4c3-3346027db1da using man macros.