Question

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.

Was it helpful?

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.

OTHER TIPS

Not the answer you are lookign for but could you just use wget instead?

On my system, your lynx command works as is. Try this and see what happens:

lynx -dump -term=xterm http://example.com >tmpfile &

We had luck running lynx --source http_setting://whatever|bash.

Running as bash allowed the background process to bypass running with my personal credentials and no tty discrepancies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top