What's wrong" For loop and pipe | "" problem

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
PiotrMP006
Posts: 29
Joined: 08 Sep 2017 06:10

What's wrong" For loop and pipe | "" problem

#1 Post by PiotrMP006 » 19 Jun 2018 06:30

Code: Select all

for /f %%a in ('gpg --list-keys --with-colons ^| findstr "Peter Pan"') do set test=%%a
With findstr "Peter Pan" don't work

With findstr Peter work

Why don't work with ""

Help
Last edited by PiotrMP006 on 19 Jun 2018 06:51, edited 1 time in total.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: What's wrong" For loop and pipe | "" problem

#2 Post by Squashman » 19 Jun 2018 06:39

You are missing the closing parentheses before the DO.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: What's wrong" For loop and pipe | "" problem

#3 Post by Squashman » 19 Jun 2018 07:34

I see you edited your question to include the closing parentheses but you have not stated whether this fixed your problem.

If it did not fix your problem you need to explain in more detail what the output of your pgp command is and what the expected output of that command should be.

pieh-ejdsch
Posts: 239
Joined: 04 Mar 2014 11:14
Location: germany

Re: What's wrong" For loop and pipe | "" problem

#4 Post by pieh-ejdsch » 19 Jun 2018 09:03

Hallo
Your findstr command will find lines with Peter OR Pan.
The for /f loop will only output the first token (word).
Use for /f "tokens=1-2" OR for /f "delims="
To set your variable.

Phil

Post Reply