LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Output match to a file using wget within a script (https://www.linuxquestions.org/questions/linux-newbie-8/output-match-to-a-file-using-wget-within-a-script-4175612024/)

learning01 08-15-2017 06:54 PM

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!

learning01 08-15-2017 07:10 PM

got it

was missing / at end of url after the variables


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