Search code examples
bashbackground-processlynxjob-control

Run lynx -dump in background?


I have a bash script mystuff containing a line like

lynx -dump http://example.com >tmpfile

and the script works fine, including this part, except when I run it non-interactively:

$ ./mystuff &
[1] 3712
$ jobs
[1]+ Stopped

The job is stopped. I find that lynx is the culprit. Even running this command directly from the bash prompt causes the job to be stopped immediately:

$ lynx -dump http://example.com >tmpfile &
[1] 1836
$ jobs
[1]+ Stopped

Why won't lynx run in the background? How can I fix this?

EDIT:

I am using lynx because I don't want to have to parse the raw HTML. The difference between wget and lynx -dump is that lynx will render the HTML; it will hide all the tags, arrange text nicely, etc.


Solution

  • Lynx wants to talk to your terminal, but can't, so it does a SIGSTP (tty input) and waits for you to foreground the process.

    As mgb said above: use wget. wget -O tmpfile http://example.com does the same thing as what you're doing with lynx above.