• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 890
  • Last Modified:

Pipe output of wget through grep using php url

I am trying to pipe the output of a wget command through grep. The url is a php file with parameters. I can do it as 2 separate commands but would like to combine them so I do not have to write the file to the disk.

This code does not work (the result is always unsuccessful) -
wget --output-file=wgetlogfile2.txt --O - http:/www.domain.com/custinv5.php?parm1=ABC&parma2=DEF | grep -qi STRING'

This code does work -  
wget --output-file=wgetlogfile2.txt --output-document=testdoc.html http:/www.domain.com/custinv5.php?parm1=ABC&parma2=DEF 
sleep 2
grep -qi 'STRING' testdoc.html
if [ $? -eq 0 ]                        

If I remove the "sleep" from the code that it works, it fails

Any ideas would be appreciated.
  • 3
1 Solution
Note special case hyphen after O means the document will be written to standard output:

wget -qO-  http:/www.domain.com/custinv5.php?parm1=ABC&parma2=DEF | grep -qi 'STRING'

Open in new window

bsg999Author Commented:

I have that in option in my command."--O -".  I had a typo when I entered the question having put two dashes in front of the "O".  There is only one dash.

I have resolved my problem.   I had to enclose the URL in quotes.

Thanks for your comment.
bsg999Author Commented:
I have resolved the issue by enclosing the URL in quotes.

bsg999Author Commented:
I did not assign an A since I should have found the solution before submitting the question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now