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

Reply

Join Date: Jun 2009
Posts: 2
Reputation: anubhav400741 is an unknown quantity at this point 
Solved Threads: 0
anubhav400741 anubhav400741 is offline Offline
Newbie Poster

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

 
0
  #1
Jun 28th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,163
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 562
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

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

 
0
  #2
Jun 28th, 2009
What is your question here? You are wanting to remove the user inputs and have it query an excel file instead?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 2
Reputation: anubhav400741 is an unknown quantity at this point 
Solved Threads: 0
anubhav400741 anubhav400741 is offline Offline
Newbie Poster

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

 
0
  #3
Jun 29th, 2009
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 ..
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,782
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 113
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

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

 
0
  #4
Jun 29th, 2009
Upload it in mysql database and use perl/php to read the data.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,163
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 562
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

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

 
0
  #5
Jun 29th, 2009
If you use a .CSV then you can use an array in bash and split it that way. Here is a start
  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
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 4
Reputation: csayantan is an unknown quantity at this point 
Solved Threads: 0
csayantan csayantan is offline Offline
Newbie Poster

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

 
0
  #6
Jul 8th, 2009
you may use awk also
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC