#!/bin/bash
currentTime=$(date +"%R")
currentdate=$(date +'%m/%d/%Y')
oldtime=$(date +%R -d "50 min ago")
echo "Current time : $currentTime"
echo "Current Date : $currentdate"
echo "Old time : $oldtime"
Response=$(curl -X GET -H "Authorization: Basic Token=" "http://targetserver.company.com:8080/v1/organizations/company/environments/environmentname/stats/apis?select=sum(is_error)&timeRange="$currentdate"%20"$currentTime"~"$currentdate"%20"$oldtime"")
echo -e "the response is: \n $Response"
没有得到任何回复?请帮助如何在shell脚本中的curl URL中使用系统日期时间/当前日期时间。
答案 0 :(得分:0)
看起来一致,但不完全确定看错了什么。您是否尝试过echo
响应行以查看其外观?如何尝试将大括号变量名称包装在大括号中并删除字符串中的引号?
Response=$(curl -X GET -H "Authorization: Basic Token=" "http://targetserver.company.com:8080/v1/organizations/company/environments/environmentname/stats/apis?select=sum(is_error)&timeRange=${currentdate}%20${currentTime}~${currentdate}%20${oldtime}")