I have written a shell script below while running this script , we have to give inputs manually, now i want that we are getting inputs in excel file ..can we automate this , this was a project for me , i am alreday late ..please help me soon

#!/bin/bash
echo -e "CREATION OF NEW MRTG LINK "
echo -e "Enter Configuration File Name "
read cfg_filename
echo -e "Enter Customer Name To Be Displayed "
read cust_name
echo -e "Enter Short Name "
read short_name
echo -e "Enter SNMP String "
read string
echo -e "Enter Router/Switch name "
read router_name
echo -e "Enter Router/Switch IP "
read router_ip
echo -e "Enter Port Details Along with "
read port_dtls
echo -e "Enter WAN IP Address "
read wan_ip
echo -e "Enter BW Allocated "
read bw
lower=`echo $short_name | tr 'A-Z' 'a-z'`
bw_config=`echo $bw/8*1000 | bc`
echo "Directory[$lower]:$lower">>/cfg/$cfg_filename
echo "Target[$lower]: -$port_dtls:$string@$router_ip:">>/cfg/$cfg_filename
echo "MaxBytes[$lower]:$bw_config">>/cfg/$cfg_filename
echo "Title[$lower]:Traffic Analysis for $cust_name.">>/cfg/$cfg_filename
echo "PageTop[$lower]: <H1>Traffic Analysis for $cust_name.</H1>">>/cfg/$cfg_filename
echo " <TABLE>">>/cfg/$cfg_filename
echo "   <TR><TD>Max Speed:</TD><TD>$bw Kbps</TD></TR>">>/cfg/$cfg_filename
echo "   <TR><TD>Port@Router/Switch:</TD><TD>$port_dtls:@$router_name</TD></TR>">>/cfg/$cfg_filename
echo "   <TR><TD>Wan Ip:</TD><TD>$wan_ip</TD></TR>">>/cfg/$cfg_filename
echo " </TABLE>">>/cfg/$cfg_filename
tail -10 /cfg/$cfg_filename
filename=`echo $cfg_filename |cut -d . -f 1`
echo $filename
echo $lower
#echo  "For Creating Index File For MRTG User"
echo  "Creating Directory"
mkdir /home/www/mrtg/$filename/$lower
echo  "Directory Created for $lower"
echo  "Creating index for $lower"
sleep 5
cat /root/scripts/index.html | sed s/eswarthemad.html/$lower.html/g > /root/scripts/tmp.html
cp /root/scripts/tmp.html /home/www/mrtg/$filename/$lower/index.html
cho "Created index for $lower"

What is your question here? You are wanting to remove the user inputs and have it query an excel file instead?

i will upload that script and a Excel(or CSV) in server and i want that while running the script it will take inputs from excel file column bu column ..

Upload it in mysql database and use perl/php to read the data.

If you use a .CSV then you can use an array in bash and split it that way. Here is a start

declare -a varray
for aline in `cat $USERFILE`
do
  varray=(`echo $aline | awk '{ split($0, ulist, ","); for(i=1; i<=11; i++) printf ulist[i] " "; }'`)

  aname=${varray[0]}
  amode=${varray[1]}

You can change the "cat userfile" to "grep ^something" to find your row and then use ${varray[N]} to get at specific elements

you may use awk also

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.