So close (scripting help)

Travis Roy travis at scootz.net
Tue Nov 9 15:30:01 EST 2004


Thanks to everybody that helped.. Steven's was the winner..

Here's my completed script(s)

Yes I know I could do it in one.. This also has the 95th percentile code 
that was given to me early.

PHP script:

<HTML>
<HEAD><TITLE>Billing.ColoSpace.Com</TITLE></HEAD>
<BODY BGCOLOR="white">
<FONT FACE="Verdana">
Welcome to the ColoSpace Billing Reporting Center<br><br>
<br>
For usage reports for individual customers, click on appropriate report 
below<br><br>

<TABLE BORDER CELLPADDING=10>

<?
system ('./test.sh');
?>

</TABLE>
<br>


</FONT>
</BODY>
</HTML>


Shell script:

#!/bin/bash

for i in `find . | egrep "\/Dailyusage.html.htm"`; do

c1=${i#./*}
cn=${c1%%/*}
f1=${c1#*/}
fn=${f1%%/*}

echo "<TR>";
echo "<TD>$cn - $fn</TD>";
echo "<TD>";
cat ./$cn/$fn/Dailyusage.html.htm | sed -e '1,/TD WIDTH="170">95th 
Percentile:/d' -e '/TD WIDTH="350"/,$d' -e 's/<[^>][^>]*>//
g' -e '/^$/d'
echo "</TD>";
echo "<TD><a href=\"$cn/$fn/Monthlyusage.html.htm\">Last Month</a></TD>";
echo "<TD><a href=\"$cn/$fn/Weeklyusage.html.htm\"> Last Week</a></TD>";
echo "<TD><a href=\"$cn/$fn/Dailyusage.html.htm\">Yesterday</a></TD>";
echo "<TD><a href=\"$cn/$fn/\">Historic</a></TD>";
echo "</TR>";

done


> On Tuesday, Nov 9th 2004 at 12:10 -0500, quoth Travis Roy:
> 
> =>Okay, with some big help from Chris I got so close.. but I still need one more
> =>thing from my script and my extreamly bad regex skills are killing me.
> =>
> =>This is the output being fed in:
> =>
> =>./Customer_Name/Feed_#/Weeklyusage.html.htm
> =>
> =>I need to strip out two things. I need the Customer_Name and Feed_#
> =>
> =>I can do it with this command from the command line, but it gives me nothing
> =>within the script.
> =>
> =>Here is my entire script so far
> =>
> =>#!/bin/bash
> =>
> =>for i in `find . | egrep "\/(Daily|Monthly|Weekly)usage.html.htm"`; do
> =>echo "<a href=\"$i\">";
> =>
> =>## Below is the command that works from the command line
> =>## but not from within this script. This gives me .Customer_Name
> =>echo $i | awk -F/ '{ print $1 }';
> =>
> =>echo "</a>";
> =>
> =>done
> 
> #! /bin/bash
> while read line
> do
>     c1=${line#./*}
>     cn=${c1%%/*}
>     f1=${c1#*/}
>     fn=${f1%%/*}
> done
> 
> I don't know if this is what you're looking for. Let me know.
> 
> You should never use `find` in a script because the commandline can blow 
> up on you.
> 




More information about the gnhlug-discuss mailing list