[UP]


Manual Reference Pages  - process_readall (3)

NAME

process_readall(3f) - [M_process] read all lines from process into single string (LICENSE:PD)

CONTENTS

Synopsis
Options
Results
Example
See Also
Author
License

SYNOPSIS

syntax:

   function process_readall(cmd,delim,ierr)  result(string)

character(len=*),intent(in) :: cmd character(len=*),intent(in),optional :: delim integer,intent(out),optional :: ierr character(len=:),allocatable :: string

OPTIONS

cmd command to pass to system
delim delimiter to place between output lines when they are concatenated. Defaults to a space
ierr check status of call.

RESULTS

process_readall
  Assuming sufficient memory is available all the output of the system command are concatenated into a string with spaces added between the output lines of the command.

EXAMPLE

Read all output of a command to a single string

     program test_process_readall
      use M_process ,only: process_readall
      implicit none
      integer :: ierr
      character(len=:),allocatable :: string
         string=process_readall(’ls’,ierr=ierr)
         write(*,*)ierr,string
      end program test_process_readall

Read all output of a command to an array using split(3f)

     program demo_process_readall
      use M_process ,only: process_readall
      !!use M_strings ,only: split
      implicit none
      integer                      :: ierr
      integer                      :: i
      character(len=:),allocatable :: string
      character(len=:),allocatable :: array(:)
         string=process_readall(’ls’,delim=NEW_LINE("A"),ierr=ierr)
         !!call split(string,array,delimiters=NEW_LINE("A"))
         !!do i=1,size(array)
         !!   write(*,’(i0,t10,"[",a,"]")’)i,trim(array(i))
         !!enddo
         !!write(*,*)string=process_readall(&
         !!& ’ls’,delim=NEW_LINE("A"),ierr=ierr)
         write(*,*)string
      end program demo_process_readall

Results:

      > 1     [Articles]
      > 2     [LIBRARY]
      > 3     [PC]
      > 4     [SHIP]
      > 5     [SPEC]
      > 6     [crib.dat]
      > 7     [doc]
      > 8     [html]
      > 9     [index.html]
      > 10    [plan.txt]
      > 11    [questions]
      > 12    [scripts]
      > 13    [tmp]

SEE ALSO

M_process(3fm)

AUTHOR

John S. Urban

LICENSE

Public Domain


process_readall (3) March 11, 2021
Generated by manServer 1.08 from 813bbf88-ccea-4f37-bcf9-3d7eb8aa9470 using man macros.