- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
related to previous questions of capturing STDOUT from a system command I went through the 2003 standard. It has this intrinsic features:
---
3 13.5.18 System environment procedures
4 COMMAND ARGUMENT COUNT () Number of command arguments
5 CPU TIME (TIME) Obtain processor time
DATE AND TIME ([DATE, TIME, ZONE, Obtain date and time
6 VALUES])
GET COMMAND ([COMMAND, Returns entire command
7 LENGTH, STATUS])
GET COMMAND ARGUMENT (NUMBER Returns a command argument
8 [, VALUE, LENGTH, STATUS])
GET ENVIRONMENT VARIABLE (NAME Obtain the value of an environment variable
[, VALUE, LENGTH, STATUS,
9 TRIM NAME])
10 IS IOSTAT END (I) Test for end-of-le value
11 IS IOSTAT EOR (I) Test for end-of-record value
SYSTEM CLOCK ([COUNT, Obtain data from the system clock
12 COUNT RATE, COUNT MAX])
----
My curiosity was about what does "GET COMMAND", "GET COMMAND ARGUMENT" really do. So, just for correctness, "COMMAND ARGUMENT" allows me to get stuff like
$ ./a.out arg1 arg2 arg3
arg1, arg2, arg3 inside my program
and I can "capture" some of the stdout (simple stuff) with
call system("export UNAVAR=`uname`")
GET_ENVIRONMENT_VARIABLE ("UNAVAR", uname_var)
? can someone just confirm this?
best!
---
3 13.5.18 System environment procedures
4 COMMAND ARGUMENT COUNT () Number of command arguments
5 CPU TIME (TIME) Obtain processor time
DATE AND TIME ([DATE, TIME, ZONE, Obtain date and time
6 VALUES])
GET COMMAND ([COMMAND, Returns entire command
7 LENGTH, STATUS])
GET COMMAND ARGUMENT (NUMBER Returns a command argument
8 [, VALUE, LENGTH, STATUS])
GET ENVIRONMENT VARIABLE (NAME Obtain the value of an environment variable
[, VALUE, LENGTH, STATUS,
9 TRIM NAME])
10 IS IOSTAT END (I) Test for end-of-le value
11 IS IOSTAT EOR (I) Test for end-of-record value
SYSTEM CLOCK ([COUNT, Obtain data from the system clock
12 COUNT RATE, COUNT MAX])
----
My curiosity was about what does "GET COMMAND", "GET COMMAND ARGUMENT" really do. So, just for correctness, "COMMAND ARGUMENT" allows me to get stuff like
$ ./a.out arg1 arg2 arg3
arg1, arg2, arg3 inside my program
and I can "capture" some of the stdout (simple stuff) with
call system("export UNAVAR=`uname`")
GET_ENVIRONMENT_VARIABLE ("UNAVAR", uname_var)
? can someone just confirm this?
best!
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've realized this can have portability issues because of the different shells where it can run...
(maybe invoque GET_ENVIRONMENT_VARIABLE to retrive $SHELL value first and act accordingly?)
(maybe invoque GET_ENVIRONMENT_VARIABLE to retrive $SHELL value first and act accordingly?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GET_COMMAND_ARGUMENT is like the C "getarg", GET_ENVIRONMENT_VARIABLE is like C "getenv". Calling SYSTEM to set an environment variable may not do anything for you, as that typically happens in another process context. There is not yet a corresponding SET_ENVIRONMENT_VARIABLE, though it might be in F2008 (I am away from my copy of that to see.) You can certainly use GET_ENVIRONMENT_VARIABLE to query any environment variables visible to you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
GET_COMMAND_ARGUMENT is like the C "getarg", GET_ENVIRONMENT_VARIABLE is like C "getenv". Calling SYSTEM to set an environment variable may not do anything for you, as that typically happens in another process context. There is not yet a corresponding SET_ENVIRONMENT_VARIABLE, though it might be in F2008 (I am away from my copy of that to see.) You can certainly use GET_ENVIRONMENT_VARIABLE to query any environment variables visible to you.
I did not remember that the process spawned by CALL SYSTEM could (would?) be in another context. Thanks for point it out.
If there's a F2008 draft... anyway to slide some usefull way to capture stdout? After all that's the "holy grail", if I can use such expression... or such need was never felt/expressed by the people deciding the language? Just curious.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran 2008 defines an EXECUTE_COMMAND_LINE intrinsic, but no provision is made for capturing output.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page