-1

In a txt file, I have a list of sites that I'd like to visit. Each of them provides a list of pages on the particular site to be visited (when called without page parameter) via list.php. The problem is that the inside loop is getting executed right after the first pass through the outside loop and that causes running multiple instances of chromium browser. What I'd like to achieve is visiting each page and closing the browser after that, then visiting another etc.

while read sites; do 
    wget -qO- "$sites/list.php" | 
        while read page; do 
           chromium "$sites/$page" & sleep 1
           pkill --oldest chromium
           wget -qO- "$sites/list.php?page=$page"
         done
done < sites.txt

2 Answers 2

1

Don't send chromium to the background:

chromium "$sites/$page" & sleep 1

Keep it in the foreground:

chromium "$sites/$page"
sleep 1
2
  • And if assuming I need it to be running on the background? I guess making a single loop by combining the URLs before the inner loop, right? Commented Nov 11, 2015 at 0:02
  • 1
    @Alexis if you run it in the background, you need to use wait. But what's the point? Commented Nov 11, 2015 at 0:04
1

After opening a new session, the code worked as expected, it was just some fluke

UPDATE: to make it reliable, the only thing needed is to increase the sleep interval by a few seconds

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.