Loading ...
Sorry, an error occurred while loading the content.

Why no output from GAWK END clause and no redirect file created?

Expand Messages
  • mycroftj
    I have been at this all day and am still stuck. I want to have a clip run GAWK code from an external file against an external data file and send all the output
    Message 1 of 2 , May 27, 2012
    • 0 Attachment
      I have been at this all day and am still stuck.
      I want to have a clip run GAWK code from an external file against an external data file and send all the output to a new external data file.

      I cannot get an output data file to be created and the output from the END clause is never captured when I obtain the program output into a NT document.

      I've tried GetInputOutput, GetOutput, GetDosOutput, Run and Shell in various forms.

      Following is a clip that creates a small data file and a small code file and tries to capture the output to a new file. I've put a sample of the GetInputOutput and RUn commands in. Comment them out one by one, etc.

      If anyone can get it to work, I would LOVE to know what I am doing wrong.

      The output should be
      Begin Clause
      Bob
      End Clause

      The small files are written to your temp folder and will be deleted when you run any clean up routines on your PC. If you don't ever do that, two additional tiny files are not going to make any difference!

      Thanks so much.

      Joy


      ^!Continue This will create a small code and data file in your temp folder. ^%NL% I'm trying to find a way to execute the code in the external file using the external data and routing all output to another external file. ^%NL%^%NL% It works when executing the Gawk.exe\ ... > output_file commands in DOS mode.^%NL%^%NL% Run this from an empty document.

      ;^!Setdebug ON

      ; Create data file
      ^!TextToFile "^$ExpandEnv(%TEMP%)$\Input_Data.txt" Mike^%NL%Bob^%NL%Mary^%NL%Sue

      ; create GAWK script code file
      ^!TextToFile "^$ExpandEnv(%TEMP%)$\GAWK_Code.txt" BEGIN { print "Begin Clause" }^%NL%/Bob/ { print $0 }^%NL%END { printf("End Clause\n") }

      ; This runs but creates no output or output file
      ;^!Run ^$GetGawkExe$ -f ^$ExpandEnv(%TEMP%)$\GAWK_Code.txt ^$ExpandEnv(%TEMP%)$\Input_Data.txt > ^$ExpandEnv(%TEMP%)$\output.txt

      ; This puts
      ;Begin Clause
      ;Bob
      ;in my current document. Where is the END statement output?
      ; Why no output file created?
      ;^$GetInputOutput(^$GetGawkExe$ -f ^$ExpandEnv(%TEMP%)$\GAWK_Code.txt ^$ExpandEnv(%TEMP%)$\Input_Data.txt > ^$ExpandEnv(%TEMP%)$\output.txt)$

      ^!prompt Done
    • mycroftj
      Found an answer. An idea came to me this morning. After playing with all the fancy DOS NT commands, just plain ^! ^%GAWK_Executable% -f ... worked. I m sure
      Message 2 of 2 , May 28, 2012
      • 0 Attachment
        Found an answer. An idea came to me this morning. After playing with all the fancy DOS NT commands, just plain ^!"^%GAWK_Executable%" -f ... worked. I'm sure somebody would have told me this eventually.

        Joy



        --- In ntb-scripts@yahoogroups.com, "mycroftj" <mycroftj@...> wrote:
        >
        > I have been at this all day and am still stuck.
        > I want to have a clip run GAWK code from an external file against an external data file and send all the output to a new external data file.
        >
        > I cannot get an output data file to be created and the output from the END clause is never captured when I obtain the program output into a NT document.
        >
        > I've tried GetInputOutput, GetOutput, GetDosOutput, Run and Shell in various forms.
        >
        > Following is a clip that creates a small data file and a small code file and tries to capture the output to a new file. I've put a sample of the GetInputOutput and RUn commands in. Comment them out one by one, etc.
        >
        > If anyone can get it to work, I would LOVE to know what I am doing wrong.
        >
        > The output should be
        > Begin Clause
        > Bob
        > End Clause
        >
        > The small files are written to your temp folder and will be deleted when you run any clean up routines on your PC. If you don't ever do that, two additional tiny files are not going to make any difference!
        >
        > Thanks so much.
        >
        > Joy
        >
        >
        > ^!Continue This will create a small code and data file in your temp folder. ^%NL% I'm trying to find a way to execute the code in the external file using the external data and routing all output to another external file. ^%NL%^%NL% It works when executing the Gawk.exe\ ... > output_file commands in DOS mode.^%NL%^%NL% Run this from an empty document.
        >
        > ;^!Setdebug ON
        >
        > ; Create data file
        > ^!TextToFile "^$ExpandEnv(%TEMP%)$\Input_Data.txt" Mike^%NL%Bob^%NL%Mary^%NL%Sue
        >
        > ; create GAWK script code file
        > ^!TextToFile "^$ExpandEnv(%TEMP%)$\GAWK_Code.txt" BEGIN { print "Begin Clause" }^%NL%/Bob/ { print $0 }^%NL%END { printf("End Clause\n") }
        >
        > ; This runs but creates no output or output file
        > ;^!Run ^$GetGawkExe$ -f ^$ExpandEnv(%TEMP%)$\GAWK_Code.txt ^$ExpandEnv(%TEMP%)$\Input_Data.txt > ^$ExpandEnv(%TEMP%)$\output.txt
        >
        > ; This puts
        > ;Begin Clause
        > ;Bob
        > ;in my current document. Where is the END statement output?
        > ; Why no output file created?
        > ;^$GetInputOutput(^$GetGawkExe$ -f ^$ExpandEnv(%TEMP%)$\GAWK_Code.txt ^$ExpandEnv(%TEMP%)$\Input_Data.txt > ^$ExpandEnv(%TEMP%)$\output.txt)$
        >
        > ^!prompt Done
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.