Python Forum
Capture grep output to a variable which includes another variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Capture grep output to a variable which includes another variable
#5
Hi Scidam,

Thanks for all your help. The only way I could get this working was with the following:
p = Popen(["grep", "-wl", what, where], stdout=True, stderr=True)
p.communicate()[0]
It now returns proper grep output, i.e., when found it returns the filename, when not found, it returns nothing.

I now need to find a way to compare the result:
IF Found
do a bunch of other stuff
ELSE
Exit

But I guess that will be for another post.

Thanks again.

kd
Reply


Messages In This Thread
RE: Capture grep output to a variable which includes another variable - by kdefilip2 - Nov-24-2019, 12:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is this a valid variable name? Skaperen 0 1 Less than 1 minute ago
Last Post: Skaperen
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 429 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  Commas issue in variable ddahlman 6 604 Apr-05-2024, 03:45 PM
Last Post: deanhystad
  Variable Explorer in spyder driesdep 1 340 Apr-02-2024, 06:50 AM
Last Post: paul18fr
  Mediapipe. Not picking up second variable stevolution2024 1 313 Mar-31-2024, 05:56 PM
Last Post: stevolution2024
Question Variable not defined even though it is CoderMerv 3 425 Mar-28-2024, 02:13 PM
Last Post: Larz60+
  optimum chess endgame with D=3 pieces doesn't give an exact moves_to_mate variable max22 1 342 Mar-21-2024, 09:31 PM
Last Post: max22
  unbounded variable akbarza 3 609 Feb-07-2024, 03:51 PM
Last Post: deanhystad
  Variable for the value element in the index function?? Learner1 8 779 Jan-20-2024, 09:20 PM
Last Post: Learner1
  Variable definitions inside loop / could be better? gugarciap 2 542 Jan-09-2024, 11:11 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020