LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-15-2017, 07:54 PM   #1
learning01
LQ Newbie
 
Registered: Jul 2012
Posts: 10

Rep: Reputation: Disabled
Question Output match to a file using wget within a script


Hi,

I have a script that scraps a webpage for the match and then is suppose to output to a file.

When I execute it from shell - it works fine however when it is executed from within the script - it is blank...

Code:
userabc@virtual-machine:~/scrap$ cat test.sh

filename="$1"
url="http://www.some-web-address.com/info-"

while read -r line
do
name="$line"
    echo "Name read from file - $name"
        echo "URL: $url$name"
        wget -qO- $url$name | hxnormalize -x | hxselect "ul" | lynx -stdin -dump -nolist | awk 'c-->0;/MATCHINGSTRING/{c=2}'
done < "$filename"

whereas if I execute the wget from shell it works fine:
wget -qO- http://www.some-web-address/info-name | hxnormalize -x | hxselect "ul" | lynx -stdin -dump -nolist | awk 'c-->0;/MATCHINGSTRING/{c=2}' >> output.txt


I would really appreciate if someone could help me out here - been going at this since few hours now...

Thanks!
 
Old 08-15-2017, 08:10 PM   #2
learning01
LQ Newbie
 
Registered: Jul 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
got it

was missing / at end of url after the variables
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wget: download if file size does not match any file in folder Si14 Linux - Software 1 04-21-2013 07:00 AM
Standard script output to screen & -x option output to file BoBeau236 Programming 6 05-10-2011 08:43 AM
Script to download file using wget linuxnewbie82 Programming 6 02-14-2007 05:48 AM
how to specify the name of the wget output file datasink Linux - Networking 2 01-23-2007 08:39 PM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 05:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration