bash - 多线终端输入
问题描述
编辑:已解决,错字。Smart me \ + " " 确实有效(反斜杠和空格有效)
我知道以前有人问过这个问题,我想参考这篇文章,其中 - 对我来说正确的回答 - 正在使用反斜杠。
不幸的是,我不知道如何。我尝试了多行 curl 请求,以下两个示例让我在这里发帖,因为它们都不起作用:
取1:
curl -X PUT localhost:8080/employees/4\
-H 'Content-type:application/json'\
-d '{"name:" "Smurf", "role": "Blueman"}'
{"timestamp":"2019-01-08T13:06:36.563+0000","status":400,"error":"Bad Request","message":"Required request body is missing: payroll.Employee payroll.EmployeeController.replaceEmployee(payroll.Employee,java.lang.Long)","path":"/employees/4-H"}curl: (3) Port number ended with 'a'
[1/2]: "name:" "Smurf" --> <stdout>
--_curl_--"name:" "Smurf"
curl: (3) Port number ended with '"'
[2/2]: "role": "Blueman" --> <stdout>
--_curl_-- "role": "Blueman"
curl: (3) Port number ended with ' '
所以我想,在使用反斜杠之前添加空格可以解决这个问题。但后来发生了这样的事情:
curl -X PUT localhost:8080/employees/4 \
-H 'Content-type:application/json' \
-d '{"name:" "Smurf", "role": "Blueman"}'
{"timestamp":"2019-01-08T13:07:32.204+0000","status":400,"error":"Bad Request","message":"JSON parse error: Unexpected character ('\"' (code 34)): was expecting a colon to separate field name and value; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('\"' (code 34)): was expecting a colon to separate field name and value\n at [Source: (PushbackInputStream); line: 1, column: 11]","path":"/employees/4"}%
所以现在它不接受 \ 作为换行符终端语法,而是尝试对其进行拦截。
我错过了什么?
解决方案
你有一个错字。尝试:
curl -X PUT localhost:8080/employees/4 \
-H 'Content-type:application/json' \
-d '{"name": "Smurf", "role": "Blueman"}'
错误消息会准确地告诉您问题所在。
推荐阅读
- python - 如何标记一个字符串(其中包含有关数学计算和浮点数的数据)?
- python - 使用python通过互联网在PC之间发送变量
- python - Gunicorn 找不到模块
- node.js - 如何将mongodb atlas与nodejs连接起来
- c++ - 将双 * 转换为 std::vector
给我错误 - javascript - 如何使用 JQuery 而不是 Javascript 来显示警报消息?
- r - 有效地存储具有大量预编译变量的数据集(并且可能只使用少数变量)
- python - Python:当您的脚本需要本地目录时,如何在云端运行 Cron 作业?
- javascript - 添加方法“FirestoreConnect”时出现错误
- sql - SYSDATETIMEOFFSET() 关闭偏移量