小编Mar*_*lar的帖子

当 curl 获得非 200 HTTP 状态时退出 bash 脚本

我有一个 bash 脚本设置来执行一些 curl 请求

for currency in EUR INR JPY
do
  curl -i --data '{"currency": "'$currency'"}' -H "Accept: application/json" -H "Content-Type: application/json" http://0.0.0.0:8080/price && echo
done
Run Code Online (Sandbox Code Playgroud)

如果其中一个 curl 响应以 http 状态 != 200 返回,有没有办法让脚本退出?

我还想保留标准的 curl 输出,例如我不想要一个只打印 http 状态代码的解决方案。

干杯

script bash shell shell-script curl

11
推荐指数
1
解决办法
8486
查看次数

Unison 不忽略路径

我试图忽略同步中的.git,.bundlenode_module目录。我尝试了一堆不同的组合试图让它工作,但每次我同步时,我都能看到所有这些目录同步到远程机器。

谁能发现我做错了什么?

~/.unison/default.prf

# Roots of the synchronization
root = /Users/bob/synced
root = ssh://bob@remotebox/synced

# Paths to synchronize
path = hack/testdir

# Some regexps specifying names and paths to ignore
ignore = Name *.log
ignore = Name .DStore
ignore = Name .DS_Store
ignore = Name *.output
ignore = Name *:*
ignore = Path {*/.git/*}
ignore = Path {*/.bundle/*}
ignore = Path {*/.vagrant/*}
ignore = Path {*/.git}
ignore = Path {*/.bundle}
ignore = Path {*/node_modules} …
Run Code Online (Sandbox Code Playgroud)

sync unison

7
推荐指数
1
解决办法
2629
查看次数

将文件复制到所有子目录

我打算使用这样的命令

FOR /R %f in (".") DO xcopt test.txt %f
Run Code Online (Sandbox Code Playgroud)

将文件复制到文件夹的所有子目录中。

当我将文件写入命令提示符时,这工作正常,但当我将其放入批处理文件并运行批处理文件时,它不起作用。

关于为什么这不能从批处理文件运行的任何想法?

谢谢

windows batch command-line

3
推荐指数
1
解决办法
5461
查看次数

标签 统计

bash ×1

batch ×1

command-line ×1

curl ×1

script ×1

shell ×1

shell-script ×1

sync ×1

unison ×1

windows ×1