bash 在后台运行 lynx -dump?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/921661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 20:55:09  来源:igfitidea点击:

Run lynx -dump in background?

bashbackground-processlynxjob-control

提问by system PAUSE

I have a bash script mystuffcontaining a line like

我有一个 bash 脚本,mystuff其中包含一行

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

and the script works fine, including this part, exceptwhen 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是罪魁祸首。即使直接从 bash 提示符运行此命令也会导致作业立即停止:

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

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

为什么lynx不会在后台运行?我怎样才能解决这个问题?

EDIT:

编辑:

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

我使用 lynx 是因为我不想解析原始 HTML。wget和之间的区别在于lynx -dumplynx 将呈现 HTML;它将隐藏所有标签,很好地排列文本等。

采纳答案by joshk0

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.

Lynx 想与您的终端对话,但不能,因此它执行 SIGSTP(tty 输入)并等待您将进程置于前台。

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

正如mgb上面所说:使用wget。wget -O tmpfile http://example.com做与你在上面用 lynx 做的事情一样的事情。

回答by Martin Beckett

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

不是您正在寻找的答案,但您可以改用wget吗?

回答by Paused until further notice.

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

在我的系统上,您的 lynx 命令按原样运行。试试这个,看看会发生什么:

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

回答by user3178410

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

我们很幸运地运行了 lynx --source http_setting://whatever|bash。

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

以 bash 身份运行允许后台进程绕过使用我的个人凭据运行并且没有 tty 差异。