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
  Functions: why use a variable "display" in a UDF as a Boolean MMartin71 3 404 May-26-2025, 05:55 AM
Last Post: DeaD_EyE
  PYTHONHOME Variable correct setting msetzerii 0 249 May-25-2025, 11:48 PM
Last Post: msetzerii
  how to get variable Azdaghost 3 620 Apr-23-2025, 07:43 PM
Last Post: deanhystad
  I trying to automate the Variable Logon button using the python code but I couldn't surendrasamudrala 0 378 Mar-07-2025, 05:02 AM
Last Post: surendrasamudrala
  not able to call the variable inside the if/elif function mareeswaran 3 750 Feb-09-2025, 04:27 PM
Last Post: mareeswaran
  How to run shell command, capture the output, then write it into textfile? tatahuft 4 1,174 Dec-20-2024, 02:13 PM
Last Post: Axel_Erfurt
  creating arbitrary local variable names Skaperen 9 2,145 Sep-07-2024, 12:12 AM
Last Post: Skaperen
  Variable Substitution call keys Bobbee 15 3,235 Aug-28-2024, 01:52 PM
Last Post: Bobbee
  how solve: local variable referenced before assignment ? trix 5 1,978 Jun-15-2024, 07:15 PM
Last Post: trix
  Variable being erased inside of if statement deusablutum 8 2,421 Jun-15-2024, 07:00 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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