# HG changeset patch # User jasonwryan # Date 1736886187 -46800 # Wed Jan 15 09:23:07 2025 +1300 # Node ID 883bdeb63eebf071e74ee5034d92284c84dff8d9 # Parent 5c0224fa5ca3a87aa61e17654385eeb2daabe2d7 Added logging diff --git a/Scripts/curconv b/Scripts/curconv --- a/Scripts/curconv +++ b/Scripts/curconv @@ -1,16 +1,39 @@ -#!/bin/sh -# from Ambrevar https://bbs.archlinux.org/viewtopic.php?pid=1568235#p1568235 +#!/bin/bash +# adaptedfrom Ambrevar https://bbs.archlinux.org/viewtopic.php?pid=1568235#p1568235 + +# File to log the arguments +curhist="$HOME/Sync/Centurion/curhistfile" -if [ $# -ne 3 ] || [ "$1" = "-h" ]; then - cat <> "$curhist" + # Print message to stdout + printf "%s\n" "$1" +} + +if (( $# != 3 )) || (( "$1" == "-h" )); then + cat <' '/div id="answer"/ {print $11}' - + +# Log the arguments +log_message "$1 $2 $3" + +# Fetch conversion and log the result +RESULT=$(curl -sA "Mozilla/5.0" "https://www.calculatorsoup.com/calculators/financial/currency-converter.php?input_value=$1&input=$2&output=$3&action=solve" \ + | awk -F'<|>' '/div id="answer"/ {print $11}') + +if [[ -n "$RESULT" ]]; then + log_message "$RESULT" + printf "\n" >> "$curhist" +else + log_message "Failed to fetch conversion result." +fi