Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

My little brother got this fortune: nohup rm -fr /& So he did...


devel / comp.lang.fortran / Running call execute_command line with a command that has " " in it

SubjectAuthor
* Running call execute_command line with a command that has " " in itPat
+* Re: Running call execute_command line with a command that has " " in itPeter Klausler US
|+- Re: Running call execute_command line with a command that has " " in itPat
|+- Re: Running call execute_command line with a command that has " " in itgah4
|`- Re: Running call execute_command line with a command that has " " in itdave thompson 2
`- Re: Running call execute_command line with a command that has " " in itgah4

1
Running call execute_command line with a command that has " " in it

<935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2635&group=comp.lang.fortran#2635

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:4e8d:0:b0:31f:403c:fd with SMTP id 13-20020ac84e8d000000b0031f403c00fdmr8082788qtp.337.1658942804825;
Wed, 27 Jul 2022 10:26:44 -0700 (PDT)
X-Received: by 2002:a05:6902:110b:b0:670:c034:4f61 with SMTP id
o11-20020a056902110b00b00670c0344f61mr20262069ybu.238.1658942804635; Wed, 27
Jul 2022 10:26:44 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 27 Jul 2022 10:26:44 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=194.233.96.165; posting-account=nFBqDgoAAADn5CYmlLWfz43I1hrjsFd-
NNTP-Posting-Host: 194.233.96.165
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com>
Subject: Running call execute_command line with a command that has " " in it
From: endurestormyseas@gmail.com (Pat)
Injection-Date: Wed, 27 Jul 2022 17:26:44 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1353
 by: Pat - Wed, 27 Jul 2022 17:26 UTC

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.

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

<b1fe79f4-9e88-4c43-8336-450894d192ccn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2636&group=comp.lang.fortran#2636

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:d86:b0:6a7:92ff:cfbc with SMTP id q6-20020a05620a0d8600b006a792ffcfbcmr17919625qkl.176.1658943402337;
Wed, 27 Jul 2022 10:36:42 -0700 (PDT)
X-Received: by 2002:a81:8841:0:b0:31d:a90f:73e2 with SMTP id
y62-20020a818841000000b0031da90f73e2mr20029280ywf.54.1658943402191; Wed, 27
Jul 2022 10:36:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 27 Jul 2022 10:36:42 -0700 (PDT)
In-Reply-To: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=ZT-cAwoAAACx2tBPXm-WZoHIT8sjnGGy
NNTP-Posting-Host: 12.154.207.45
References: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b1fe79f4-9e88-4c43-8336-450894d192ccn@googlegroups.com>
Subject: Re: Running call execute_command line with a command that has " " in it
From: pklausler@nvidia.com (Peter Klausler US)
Injection-Date: Wed, 27 Jul 2022 17:36:42 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1699
 by: Peter Klausler US - Wed, 27 Jul 2022 17:36 UTC

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=""""

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

<65c29cd7-366c-4264-b2e6-800143096aadn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2637&group=comp.lang.fortran#2637

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5c91:0:b0:31f:2385:3633 with SMTP id r17-20020ac85c91000000b0031f23853633mr19372700qta.674.1658943634182;
Wed, 27 Jul 2022 10:40:34 -0700 (PDT)
X-Received: by 2002:a81:6356:0:b0:31c:f779:53a4 with SMTP id
x83-20020a816356000000b0031cf77953a4mr19229540ywb.289.1658943634029; Wed, 27
Jul 2022 10:40:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 27 Jul 2022 10:40:33 -0700 (PDT)
In-Reply-To: <b1fe79f4-9e88-4c43-8336-450894d192ccn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=194.233.96.78; posting-account=nFBqDgoAAADn5CYmlLWfz43I1hrjsFd-
NNTP-Posting-Host: 194.233.96.78
References: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com> <b1fe79f4-9e88-4c43-8336-450894d192ccn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <65c29cd7-366c-4264-b2e6-800143096aadn@googlegroups.com>
Subject: Re: Running call execute_command line with a command that has " " in it
From: endurestormyseas@gmail.com (Pat)
Injection-Date: Wed, 27 Jul 2022 17:40:34 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1864
 by: Pat - Wed, 27 Jul 2022 17:40 UTC

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 :)

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

<05c8a144-c790-4a7d-ad1b-be0d785c84cfn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2638&group=comp.lang.fortran#2638

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:14cc:b0:31f:2426:cd6c with SMTP id u12-20020a05622a14cc00b0031f2426cd6cmr19285283qtx.147.1658943914773;
Wed, 27 Jul 2022 10:45:14 -0700 (PDT)
X-Received: by 2002:a25:6ec6:0:b0:671:6dfe:336d with SMTP id
j189-20020a256ec6000000b006716dfe336dmr8181734ybc.319.1658943914570; Wed, 27
Jul 2022 10:45:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 27 Jul 2022 10:45:14 -0700 (PDT)
In-Reply-To: <b1fe79f4-9e88-4c43-8336-450894d192ccn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:bc00:4a16:395a:7895;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:bc00:4a16:395a:7895
References: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com> <b1fe79f4-9e88-4c43-8336-450894d192ccn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <05c8a144-c790-4a7d-ad1b-be0d785c84cfn@googlegroups.com>
Subject: Re: Running call execute_command line with a command that has " " in it
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 27 Jul 2022 17:45:14 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1845
 by: gah4 - Wed, 27 Jul 2022 17:45 UTC

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.

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

<d8e4c7df-ad7f-4af7-8d4d-41ef159f5cb6n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2639&group=comp.lang.fortran#2639

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5a48:0:b0:31e:f288:3d68 with SMTP id o8-20020ac85a48000000b0031ef2883d68mr19359892qta.111.1658945264424;
Wed, 27 Jul 2022 11:07:44 -0700 (PDT)
X-Received: by 2002:a05:6902:10ca:b0:671:3616:9147 with SMTP id
w10-20020a05690210ca00b0067136169147mr12655389ybu.105.1658945264230; Wed, 27
Jul 2022 11:07:44 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 27 Jul 2022 11:07:44 -0700 (PDT)
In-Reply-To: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:bc00:4a16:395a:7895;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:bc00:4a16:395a:7895
References: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d8e4c7df-ad7f-4af7-8d4d-41ef159f5cb6n@googlegroups.com>
Subject: Re: Running call execute_command line with a command that has " " in it
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 27 Jul 2022 18:07:44 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1588
 by: gah4 - Wed, 27 Jul 2022 18:07 UTC

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.

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

<jhjrfh91m6uih4c055k3g8q8bmm84bbd3s@4ax.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2702&group=comp.lang.fortran#2702

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dave_thompson_2@comcast.net
Newsgroups: comp.lang.fortran
Subject: Re: Running call execute_command line with a command that has " " in it
Date: Thu, 18 Aug 2022 01:29:45 -0400
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <jhjrfh91m6uih4c055k3g8q8bmm84bbd3s@4ax.com>
References: <935cf336-1707-4e05-ad63-458dbd36d891n@googlegroups.com> <b1fe79f4-9e88-4c43-8336-450894d192ccn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="a2c135c6b8759c29ba5fe18e67532e7c";
logging-data="909624"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+491/F6KWiQgvZlzuS7wkZX/v3Yywc60M="
Cancel-Lock: sha1:WQtvMLlIlUHKPNbIp22eL4Ce+RE=
X-Newsreader: Forte Agent 3.3/32.846
 by: dave_thompson_2@comcast.net - Thu, 18 Aug 2022 05:29 UTC

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" )

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor