943,590 Members | Top Members by Rank

Ad:
Jun 28th, 2009
0

Please it is very Important for me ....Please help me ...

Expand Post »
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
Shell Scripting Syntax (Toggle Plain Text)
  1. #!/bin/bash
  2. echo -e "CREATION OF NEW MRTG LINK "
  3. echo -e "Enter Configuration File Name "
  4. read cfg_filename
  5. echo -e "Enter Customer Name To Be Displayed "
  6. read cust_name
  7. echo -e "Enter Short Name "
  8. read short_name
  9. echo -e "Enter SNMP String "
  10. read string
  11. echo -e "Enter Router/Switch name "
  12. read router_name
  13. echo -e "Enter Router/Switch IP "
  14. read router_ip
  15. echo -e "Enter Port Details Along with "
  16. read port_dtls
  17. echo -e "Enter WAN IP Address "
  18. read wan_ip
  19. echo -e "Enter BW Allocated "
  20. read bw
  21. lower=`echo $short_name | tr 'A-Z' 'a-z'`
  22. bw_config=`echo $bw/8*1000 | bc`
  23. echo "Directory[$lower]:$lower">>/cfg/$cfg_filename
  24. echo "Target[$lower]: -$port_dtls:$string@$router_ip:">>/cfg/$cfg_filename
  25. echo "MaxBytes[$lower]:$bw_config">>/cfg/$cfg_filename
  26. echo "Title[$lower]:Traffic Analysis for $cust_name.">>/cfg/$cfg_filename
  27. echo "PageTop[$lower]: <H1>Traffic Analysis for $cust_name.</H1>">>/cfg/$cfg_filename
  28. echo " <TABLE>">>/cfg/$cfg_filename
  29. echo " <TR><TD>Max Speed:</TD><TD>$bw Kbps</TD></TR>">>/cfg/$cfg_filename
  30. echo " <TR><TD>Port@Router/Switch:</TD><TD>$port_dtls:@$router_name</TD></TR>">>/cfg/$cfg_filename
  31. echo " <TR><TD>Wan Ip:</TD><TD>$wan_ip</TD></TR>">>/cfg/$cfg_filename
  32. echo " </TABLE>">>/cfg/$cfg_filename
  33. tail -10 /cfg/$cfg_filename
  34. filename=`echo $cfg_filename |cut -d . -f 1`
  35. echo $filename
  36. echo $lower
  37. #echo "For Creating Index File For MRTG User"
  38. echo "Creating Directory"
  39. mkdir /home/www/mrtg/$filename/$lower
  40. echo "Directory Created for $lower"
  41. echo "Creating index for $lower"
  42. sleep 5
  43. cat /root/scripts/index.html | sed s/eswarthemad.html/$lower.html/g > /root/scripts/tmp.html
  44. cp /root/scripts/tmp.html /home/www/mrtg/$filename/$lower/index.html
  45. cho "Created index for $lower"
Last edited by Ancient Dragon; Jun 28th, 2009 at 7:33 am. Reason: add code tags and disable smilies
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anubhav400741 is offline Offline
2 posts
since Jun 2009
Jun 28th, 2009
0

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?
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jun 29th, 2009
0

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 ..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anubhav400741 is offline Offline
2 posts
since Jun 2009
Jun 29th, 2009
0

Re: Please it is very Important for me ....Please help me ...

Upload it in mysql database and use perl/php to read the data.
Reputation Points: 769
Solved Threads: 128
Banned
ithelp is offline Offline
1,910 posts
since May 2006
Jun 29th, 2009
0

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
bash Syntax (Toggle Plain Text)
  1. declare -a varray
  2. for aline in `cat $USERFILE`
  3. do
  4. varray=(`echo $aline | awk '{ split($0, ulist, ","); for(i=1; i<=11; i++) printf ulist[i] " "; }'`)
  5.  
  6. aname=${varray[0]}
  7. 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
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jul 8th, 2009
0

Re: Please it is very Important for me ....Please help me ...

you may use awk also
Reputation Points: 10
Solved Threads: 0
Newbie Poster
csayantan is offline Offline
4 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: getopts
Next Thread in Shell Scripting Forum Timeline: Syntax to use a variable in a for loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC