我想要写一个脚本在脚本中会执行命令 curl -S httplocalhost9040healthInfo 输出的正确结果格式如下:分支 useryslhealthInfo br提交id 5d7e4801eafb0710da48ddb8bded629d6dc8a707 br提交人 yangshilong br提交时间 2023-04-04 13 50 06 br版本号 100 br。错误的结
#!/bin/bash result=$(curl -S "http://localhost:9040/healthInfo") # 执行curl命令,将输出结果保存到变量result中 if [[ $result =~ "分支:" && $result =~ "提交id:" && $result =~ "提交人:" && $result =~ "提交时间:" && $result =~ "版本号:" ]]; then # 如果输出结果符合正确格式 echo $result # 输出结果 else # 如果输出结果不符合正确格式 echo "接口访问异常,某某服务未正常运行,请排查" # 输出错误信息 fi
原文地址: http://www.cveoy.top/t/topic/brZF 著作权归作者所有。请勿转载和采集!