 | |
| anubhav400741 | Jun 28th, 2009 4:19 am | |
| Please it is very Important for me ....Please help me ... 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" |
| sknake | Jun 28th, 2009 1:26 pm | |
| Re: Please it is very Important for me ....Please help me ... What is your question here? You are wanting to remove the user inputs and have it query an excel file instead? |
| anubhav400741 | Jun 29th, 2009 3:44 am | |
| Re: Please it is very Important for me ....Please help me ... 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 .. |
| ithelp | Jun 29th, 2009 5:11 am | |
| Re: Please it is very Important for me ....Please help me ... Upload it in mysql database and use perl/php to read the data. |
| sknake | Jun 29th, 2009 3:20 pm | |
| Re: Please it is very Important for me ....Please help me ... 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 |
| csayantan | Jul 8th, 2009 8:52 am | |
| Re: Please it is very Important for me ....Please help me ... you may use awk also |
| All times are GMT -4. The time now is 3:12 pm. | |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC