bash - 无法在 .sh 脚本中使用“&”作为后台 HTTPie http 请求
问题描述
这是如何从 BASH 提示中工作的:
/testproj> http http://localhost:5000/ping/ &
[1] 10733
(env)
/testproj> HTTP/1.0 200 OK
Content-Length: 2
Content-Type: application/json
Date: Sat, 17 Nov 2018 19:27:01 GMT
Server: Werkzeug/0.14.1 Python/3.6.4
{}
...但从 a 执行时失败.sh
:
/testproj> cat x.sh
http http://localhost:5000/ping/ &
(env)
/testproj> ./x.sh
(env)
/testproj> HTTP/1.0 405 METHOD NOT ALLOWED
Allow: GET, HEAD, OPTIONS
Content-Length: 178
Content-Type: text/html
Date: Sat, 17 Nov 2018 19:29:00 GMT
Server: Werkzeug/0.14.1 Python/3.6.4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
?
编辑:http
是 HTTPie
编辑:type http
给http is hashed (/testproj/env/bin/http)
编辑:一个人可以重现错误http http://www.google.com </dev/null &
(感谢@e36freak)
编辑:来自 IRC 上的 e36freak:
这似乎是一个问题,
stdin
我得到了同样的错误,只是http http://www.google.com </dev/null
http
想stdin
附加到tty
它看起来
无论出于何种原因
在手册页中找不到它,但我确定它就在那里
解决方案
您最喜欢需要包含--ignore-stdin
阻止 httpie 尝试读取它的选项。参见:https ://httpie.org/doc#scripting
推荐阅读
- java - 无法使用改造 2 转换器
- python - 设置自定义名称和文件类型 youtube_dl python
- python - Python中带有守护线程的finally子句
- javascript - Ionic 5 Angular 在应用程序浏览器中运行 .executeScript() 不起作用
- actionscript-3 - 如何删除创建的孩子,并重新启动动画
- ios - SecurityApplicationGroupIdentifier 的应用程序组返回 nil
- r - 使用 fastDummies 创建年份/地区虚拟变量
- javascript - 如何批量插入对象数组并在 NodeJS 中插入 MySQL
- arrays - ESP32 从 HTTP GET 响应创建一个可访问的 JSON 数组
- python - 使用 Python 快速抓取动态网页