我在这里读了很多,但仍然找不到如何解决这个问题:
steps.wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
steps.withCredentials([steps.usernamePassword(credentialsId: "test", usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
steps.sh """
curl --silent -u \${GIT_USERNAME}:\${GIT_PASSWORD} -H "Content-Type: application/json" -X POST https://some.url --data-binary @- <<-EOF
{
"state": "$STATE",
"key": "\$JOB_NAME",
"name": "\$BUILD_TAG",
"url": "\$BUILD_URL",
"description": "$DESCRIPTION"
}
EOF"""
Run Code Online (Sandbox Code Playgroud)
它位于詹金斯共享库中。我读过我必须避免空格,但我没有看到我在这里创建了哪些空格。我不断收到此错误:
line 11: warning: here-document at line 2 delimited by end-of-file (wanted `EOF')
Run Code Online (Sandbox Code Playgroud) 我需要使用 向网站发出请求curl,但网站没有在 tls 中提供中间证书。
我的意思是说:
当使用 TLS 连接到服务器时,它必须(rfc5246 F.1.1、rfc5246 7.4.2)向客户端提供足以验证服务器证书的所有证书。这意味着当连接到www.google.com时,它会为我提供主机证书 (*.google.com) 和中间证书 (GTS CA 1C3) 和根证书 (GTS Root R1)。当连接到问题站点时,它仅提供主机证书。
示例:openssl s_client -connect google.com:443 -showcerts 2>&1 < /dev/null- 给您 3 个证书。
对于大多数浏览器来说这是可以的,但对于 CURL 来说就不行了。
所以我必须使用curl --insecure或手动更新该网站的捆绑包。
我想让我的连接安全,但自动进行。
是否有某种工具可以从 url 构建完整的证书链,根据根 CA 捆绑包对其进行验证,并输出值以在curl --insecure --pinnedpubkey <value>验证失败时使用或不使用?
我跟踪了一个curl命令:
strace -s 2000 -f curl google.com
Run Code Online (Sandbox Code Playgroud)
并看到 2 个 DNS 查询
recvfrom(3, "\302\325\201\200\0\1\0\1\0\0\0\0\6google\3com\0\0\34\0\1\6google\3com\0\0\34\0\1\0\0\0\362\0\20*\0\24P@\t\10\v\0\0\0\0\0\0 \16", 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.65.7")}, [28->16]) = 66
recvfrom(3, "X\320\201\200\0\1\0\1\0\0\0\0\6google\3com\0\0\1\0\1\6google\3com\0\0\1\0\1\0\0\1)\0\4\216\372\263\356", 65536, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.65.7")}, [28->16]) = 54
Run Code Online (Sandbox Code Playgroud)
然后,我看到对 142.250.179.238 的 connect() 系统调用,这是 Google 的 IP。
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("142.250.179.238")}, 16) = 0
Run Code Online (Sandbox Code Playgroud)
我相信2个recvfrom调用之一包含IP“142.250.179.238”,否则curl无法知道要连接的IP。
我的问题:2个recvfrom字符串的格式是什么?以及如何解析它来获取IP地址?
"\302\325\201\200\0\1\0\1\0\0\0\0\6google\3com\0\0\34\0\1\6google\3com\0\0\34\0\1\0\0\0\362\0\20*\0\24P@\t\10\v\0\0\0\0\0\0 \16"
"X\320\201\200\0\1\0\1\0\0\0\0\6google\3com\0\0\1\0\1\6google\3com\0\0\1\0\1\0\0\1)\0\4\216\372\263\356"
Run Code Online (Sandbox Code Playgroud) 我正在尝试抓取一个网站以使用 API 获取页面。当我发出命令时
cd desktop/mysite ; curl -O https://api.mysite.com/info?page=2
Run Code Online (Sandbox Code Playgroud)
我在桌面上获取数据。然后我想循环 2 到 100 页。我无法将 json 文件放到我的桌面上。有人可以更正我的代码吗?
cd desktop/mysite ; curl -O https://api.mysite.com/info?page=2
Run Code Online (Sandbox Code Playgroud) 该man curl入门curl -O说:
如果要将文件保存在不同的目录中,请确保更改 cur? 在使用 -O, --remote-name 标志调用 curl 之前租用工作目录!
为什么不能将文件下载到特定目录,而必须cd /example将文件下载到特定目录?
我知道用wget这种方式是可能的:
wget -P /example https://example.com/file
Run Code Online (Sandbox Code Playgroud)
但我确实想知道为什么它似乎不是与curl.
我正在尝试编写一个脚本,该脚本将凭据保存到 .netrc 文件中,然后从文件中读取,以便将它们传递给 curl 命令并保存返回的 cookie 文件以备将来使用。我很感兴趣,如果这是传递用户名和密码的安全方式,并且如果我试图访问的服务器是通过 HTTP 访问的,那么如果中间有攻击者,他们是否能够嗅探凭据。
#!/bin/bash
IP="192.168.0.1"
user="Administrator"
pass="Password1234"
function credentials {
mkdir "${HOME}"/.netrc
rm "${HOME}"/.netrc/credentials.txt
touch "${HOME}"/.netrc/credentials.txt
{ echo "machine ${IP}"; echo "login ${user}"; echo "password ${pass}"; } >> "${HOME}"/.netrc/credentials.txt
chmod 600 "${HOME}"/.netrc/credentials.txt
}
function cookie {
curl -v -c cookie.txt -n "${HOME}"/.netrc/credentials.txt http://"${IP}"/setup.php
}
credentials
cookie
Run Code Online (Sandbox Code Playgroud)
我已经检查和credentials.txt文件被正确保存在相应的目录和证书具有正确的权限,但是当我尝试运行cookie的,我有以下错误:Couldn't find host 192.168.0.1 in the .netrc file; using defaults。为什么 curl 无法从credentials.txt 文件中获取配置的用户名和密码?
我想将图像下载到
https://lorempixel.com/1280/320/nature/1/
Run Code Online (Sandbox Code Playgroud)
和curl。
curl https://www.python.org/static/apple-touch-icon-144x144-precomposed.png > image.png 工作 正常!(来自/sf/ask/2263151621/)
问题https://lorempixel.com/1280/320/nature/1/是它没有文件扩展名,例如.jpg或.png。
尝试:
curl https://lorempixel.com/1280/320/nature/1 > test.jpg
curl -O https://lorempixel.com/1280/320/nature/1/
...远程文件名没有长度!...
curl -O https://lorempixel.com/1280/320/nature/1/ > test.jpg
...远程文件名没有长度!...
并尝试curl -Ov(详细)和其他尝试但没有成功。
有可能吗curl?
我有一个 python 服务器在树莓派的 8000 端口上运行,并想让它在本地网络中访问,但目前无法正常工作。
接口 wlan0 配置了 IP 10.0.0.69 和网络掩码 255.255.255.0。
我无法访问本地网络中的服务器(从不同的主机):
root@DESKTOP-Lukas:~# curl http://10.0.0.69:8000
curl: (7) Failed to connect to 10.0.0.69 port 8000: Connection refused
Run Code Online (Sandbox Code Playgroud)
我也无法从树莓派访问服务器:
lukas@raspberrypi:~ $ curl http://10.0.0.69:8000
curl: (7) Failed to connect to 10.0.0.69 port 8000: Connection refused
Run Code Online (Sandbox Code Playgroud)
服务器正在运行并侦听端口 8000:
lukas@raspberrypi:~ $ sudo netstat -tnlp | ack 8000
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 743/python
Run Code Online (Sandbox Code Playgroud)
服务器在使用 localhost 时正确响应:
lukas@raspberrypi:~ $ curl localhost:8000
<h1>Not Found</h1><p>The requested URL / was not found on this server.</p>
Run Code Online (Sandbox Code Playgroud)
防火墙允许端口 8000 …
在curl用于获取脚本然后执行它的 shell 脚本中,这两种方法是否有实质性不同?
curl http://address-to-some-script/dosomething.sh | sudo tee /usr/bin/dosomething.sh
Run Code Online (Sandbox Code Playgroud)
……对……
sudo curl http://address-to-some-script/dosomething.sh >> /usr/bin/dosomething.sh
Run Code Online (Sandbox Code Playgroud)
在第二个命令sudo之前curl,有一些事情让我停下来,但我无法阐明它是否或如何与第一个不同(风险更大?)。
我需要在 curl 中包含变量
for fname in "assets/*.drx"; do
echo $fname
curl -F file=@"$fname" "http://someurl.com/"
echo $fnamename
done
Run Code Online (Sandbox Code Playgroud)
结果:
assets/5baa5caa414f1d7786e86d03_1545903119.11.drx
curl: (26) couldn't open file "assets/*.drx"
assets/5baa5caa414f1d7786e86d03_1545903119.11.drx
Run Code Online (Sandbox Code Playgroud)
似乎 curl 使用 glob 表达式,但 echo 使用实际文件名。为什么 curl 的行为是这样的?为什么 echo 会看到实际变量以及如何在 curl 中使用文件名?