Most of the time while buying online I have to convert USD to INR. By using following script you can do the task by simply entering the amount in USD. You must need lynx command and Internet connection cause it fetches currency rate from net.

To install lynx via yum

yum install lynx

To install lynx via apt-get

apt-get install lynx

Copy & save following as currency.sh in your home folder

#!/bin/bash
# A shell script to to convert USD to INR
# ----------------------------------------------------------------------------
# Written by Vidyadhar 
# Contact techienote.com@gmail.com; vidyadhards@gmail.com
# ----------------------------------------------------------------------------
lynx -dump "http://techienote.com" > /tmp/net
NET=`cat /tmp/net | grep -m 1 "TechieNote" | cut -d "]" -f 2 | cut -d " " -f 1`
TEXT=TechieNote
if [ "$NET" = "$TEXT" ]; then
        echo "You are connected to the Net"
else
        echo "Please check your net connection and run the script again"
exit
fi
echo "Insert the USD you want to convert in INR"
read CONV
lynx -dump "http://www.google.com/finance/converter?a=$CONV&from=USD&to=INR" > /tmp/conv
cat /tmp/conv | grep Convert | sed 's/Convert//g' | sed 's/^[ \t]*//;s/[ \t]*$//'
rm -rf /tmp/net
rm -rf /tmp/conv

How Do I Use This Script?
Just run

sh ~/currency.sh
Shell Script to Convert USD to INR
Tagged on:                                                                                     

Leave a Reply

Your email address will not be published. Required fields are marked *