• Re: Running call execute_command line with a command that has " " in it

    From Pat@21:1/5 to Peter Klausler US on Wed Jul 27 10:40:33 2022
    On Wednesday, 27 July 2022 at 20:36:43 UTC+3, Peter Klausler US wrote:
    On Wednesday, July 27, 2022 at 10:26:46 AM UTC-7, Pat wrote:
    I have a Fortran 90 program that needs to run a bash command in it for text file manipulation.

    Unfortunately the compiler gets confused between the "" for the command and the "" for the bash command

    Example:
    call execute_command_line("cat test.txt | awk '{$1=$NF=""; print $0}' > output.txt")

    How do I fix this?

    Thanks.
    Replace the two double quotes within the character literal constant with four double quotes: $NF=""""

    Thanks, it works :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Klausler US@21:1/5 to Pat on Wed Jul 27 10:36:42 2022
    On Wednesday, July 27, 2022 at 10:26:46 AM UTC-7, Pat wrote:
    I have a Fortran 90 program that needs to run a bash command in it for text file manipulation.

    Unfortunately the compiler gets confused between the "" for the command and the "" for the bash command

    Example:
    call execute_command_line("cat test.txt | awk '{$1=$NF=""; print $0}' > output.txt")

    How do I fix this?

    Thanks.

    Replace the two double quotes within the character literal constant with four double quotes: $NF=""""

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Pat@21:1/5 to All on Wed Jul 27 10:26:44 2022
    I have a Fortran 90 program that needs to run a bash command in it for text file manipulation.

    Unfortunately the compiler gets confused between the "" for the command and the "" for the bash command

    Example:
    call execute_command_line("cat test.txt | awk '{$1=$NF=""; print $0}' > output.txt")

    How do I fix this?

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to Pat on Wed Jul 27 11:07:44 2022
    On Wednesday, July 27, 2022 at 10:26:46 AM UTC-7, Pat wrote:

    (snip)

    call execute_command_line("cat test.txt | awk '{$1=$NF=""; print $0}' > output.txt")

    The other complication, which it seems you already figured out,
    is that the shell will expand $ variables inside double quotes, but not
    single quotes. Combined with awk's use of $, that can be tricky.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to Peter Klausler US on Wed Jul 27 10:45:14 2022
    On Wednesday, July 27, 2022 at 10:36:43 AM UTC-7, Peter Klausler US wrote:

    (snip)

    Replace the two double quotes within the character literal constant with four double quotes: $NF=""""

    Unix is pretty consistent on its quoting conventions, unlike another popular OS.

    You have to double quotes as they are seen by the shell, and the double them
    as they are seen by awk. Tradition is to run Bourne shell, but otherwise there is still
    a shell between you and awk, to process quotes.

    If you are using CMD.EXE as your shell, I am much less sure how to do it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dave_thompson_2@comcast.net@21:1/5 to pklausler@nvidia.com on Thu Aug 18 01:29:45 2022
    On Wed, 27 Jul 2022 10:36:42 -0700 (PDT), Peter Klausler US <pklausler@nvidia.com> wrote:

    On Wednesday, July 27, 2022 at 10:26:46 AM UTC-7, Pat wrote:
    I have a Fortran 90 program that needs to run a bash command in it for text file manipulation.

    Unfortunately the compiler gets confused between the "" for the command and the "" for the bash command

    Example:
    call execute_command_line("cat test.txt | awk '{$1=$NF=""; print $0}' > output.txt")

    How do I fix this?

    Thanks.

    Replace the two double quotes within the character literal constant with four double quotes: $NF=""""

    Or more sneakily use the fact that an awk variable (not field) is
    implictly initalized to the empty string, plus the default operand for
    print is $0 and awk reads files just as well as cat:

    ...( "awk '{$1=$NF=empty;print}' test.txt >output.txt" )

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)