-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·40 lines (33 loc) · 988 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
DATE=$1
if [ -z "$DATE" ]
then
DATE=$(date +%d/%m/%Y)
fi
SERIE=$2
if [ -z "$SERIE" ]
then
SERIE=1
fi
BCB_URL="https://www3.bcb.gov.br/wssgs/services/FachadaWSSGS"
BCBWSACTION="getValor"
ENVELOPE="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://schemas.conversesolutions.com/xsd/dmticta/v1\">"
ENVELOPE+="<soapenv:Header/>"
ENVELOPE+="<soapenv:Body>"
ENVELOPE+="<v1:$BCBWSACTION>"
ENVELOPE+="<v1:in0>$SERIE</v1:in0>"
ENVELOPE+="<v1:in1>$DATE</v1:in1>"
ENVELOPE+="</v1:$BCBWSACTION>"
ENVELOPE+="</soapenv:Body>"
ENVELOPE+="</soapenv:Envelope>"
RESULT=$(curl -s --header "Content-Type: text/xml;charset=UTF-8" \
--header "SOAPAction:$BCBWSACTION" \
-d "$ENVELOPE" \
-X POST https://www3.bcb.gov.br/wssgs/services/FachadaWSSGS)
if [[ $RESULT =~ ([0-9]{1,2}\.[0-9]{3,5}) ]]; then
VALUE=${BASH_REMATCH[1]}
else
echo "Value not found to '$DATE'"
exit
fi
echo "Value to $DATE is R$ $VALUE"