Skip to content

Instantly share code, notes, and snippets.

@altmas5
Last active April 3, 2017 17:13
Show Gist options
  • Select an option

  • Save altmas5/5963fc26286c8f6662a40ce8e274dfb5 to your computer and use it in GitHub Desktop.

Select an option

Save altmas5/5963fc26286c8f6662a40ce8e274dfb5 to your computer and use it in GitHub Desktop.
Obtener el tipo de cambio del banco central desde bash
#/bin/bash
> data.xml
dia=$(date +%d)
mes=$(date +%m)
anio=$(date +%Y)
hoy=$dia"/"$mes"/"$anio;
echo '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://servicios.bcn.gob.ni/">' >> data.xml
echo '<soapenv:Header/>' >> data.xml
echo '<soapenv:Body>' >> data.xml
echo '<ser:RecuperaTC_Dia>' >> data.xml
echo '<ser:Ano>'"$anio"'</ser:Ano>' >> data.xml
echo '<ser:Mes>'"$mes"'</ser:Mes>' >> data.xml
echo '<ser:Dia>'"$dia"'</ser:Dia>' >> data.xml
echo '</ser:RecuperaTC_Dia>' >> data.xml
echo '</soapenv:Body>' >> data.xml
echo '</soapenv:Envelope>' >> data.xml
xml=`/usr/bin/curl -s -X POST -H "Content-Type: text/xml" -H "SOAPAction: \"http://servicios.bcn.gob.ni/RecuperaTC_Dia\"" -d @data.xml https://servicios.bcn.gob.ni/Tc_Servicio/ServicioTC.asmx?WSDL`
tc=`echo $xml | xml_grep 'RecuperaTC_DiaResult' --text_only`;
echo 'El tipo de cambio de hoy '"$hoy"' es U$1 = C$ '"$tc"'';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment