Menu

How to process command output

2020-06-28
2020-06-29
  • Maurizio Bongini

    HI
    Env Windows 7 gnucobol 3.1-dev.0
    To process command ouput i use (example..)

                                      CALL 'SYSTEM' USING  'ipconfig >output.txt'
    

    then i open output.txt ,read records ,process records and then close ....
    it function ...
    Is this the correct way to process command output ?
    ...or there is a simplier way ?
    thanks in advance
    Maurizio

     
    • Simon Sobisch

      Simon Sobisch - 2020-06-29

      This is definitely a reasonable approach that will work with most compilers.

      There's no "simple" or "correct" approach here. Two other options you may want to look at that use pipes instead of redirection:

       
  • David Wall

    David Wall - 2020-06-28

    I can't imagine a simpler method - you've told the OS what command you want to execute and where to put the resulting output. - perfect.
    I tend to do a similar thing to decide if a file is present or not by 'dir > textfile - then I open the textfile & read it -
    IF I get any records then the file is present - but if it takes the at end path then it's not.

     
    • Simon Sobisch

      Simon Sobisch - 2020-06-29

      Minimal topic drift - You may want to have a look at CBL_CHECK_FILE_EXIST [if there are any questions on this please create a new topic].

       
  • Maurizio Bongini

    Hi
    i opened this topic just to know if another method is available ....

     
    • Simon Sobisch

      Simon Sobisch - 2020-06-29

      Sounds like my suggestions above are relevent than - so everything is fine, isn't it?

       

Anonymous
Anonymous

Add attachments
Cancel