【发布时间】:2021-07-15 19:40:12
【问题描述】:
感谢它的 API,我正在尝试从服务器获取一些数据(更准确地说是 mac 地址)。数据是 json 格式,我不能得到我期望的输出。顺便说一句,我想将我期望的输出(所以 json 数据)重定向到一个文件。
例如:我正在这样做:
curl -i -H "Accept: application/json" -X GET https://internal.mycompany.com/api/install/get_macs.php?token=xxxxxxxxxxxxxxx" > mac.txt
我得到的输出是这样的:
[1] 1308
mo@servertest:~$
HTTP/1.1 200 OK
Date: Wed, 21 Apr 2021 15:13:19 GMT
Server: Apache/2.4.38 (Debian)
Content-Length: 62
Content-Type: text/html; charset=UTF-8
[{"mactabwifi":"","mactabwired":"","maccam":"","macnuc":null}]
而且我必须再次按 Enter 键,否则它不会做任何事情。一旦我按下回车,我就会得到这个:
[1]+ Done curl -i -H "Accept: application/json" -X GET https://internal.mycompany.com/api/install/get_macs.php?token=xxxxxxxxxxxx
你知道如何在不按第二次回车的情况下只获取我需要的数据吗?
顺便说一句,在这一切之后,当我对我的文件 mac.txt 做猫时,什么都没有..
感谢您的帮助!
【问题讨论】:
-
this 是否回答了您的问题?