?
Solved

Pipe output of wget through grep using php url

Posted on 2011-10-12
4
Medium Priority
?
811 Views
Last Modified: 2012-05-12
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 ]                        
then                                  
   ....
else
 ......
fi

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

Any ideas would be appreciated.
0
Comment
Question by:bsg999
  • 3
4 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 36959708
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

0
 

Author Comment

by:bsg999
ID: 36959829

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.
0
 

Accepted Solution

by:
bsg999 earned 0 total points
ID: 36959835
I have resolved the issue by enclosing the URL in quotes.

Thanks.
0
 

Author Closing Comment

by:bsg999
ID: 36978280
I did not assign an A since I should have found the solution before submitting the question.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question