Overly complex...
Three errors:
1) Line 15. I believe $webpg$ should be $webpgnm
2) Line 15. You have "<body><body ...". There should be only one. There are some other HTML errors too.
3) Line 28. you use a "sed" with no output file specification - thus the output is sent to the terminal.
I say overly complex because you are using multiple echo commands for what could be more easily done with a "hereis" input.
Here is an example of a cleaned up version:
Code:
#!/bin/bash
#
# Script to build server statistics Lstats.html
#
varupt=$(uptime)
serverid="test.net - "
webpgnm="Lstats.html"
tempvar=""
tempnum=0
fontsz="2"
hfontsz="2"
cat >$webpgnm <<-EOF
<html>
<head>
<title>Server Stats</title>
</head>
<body bgcolor="#E7DFAD" TEXT="#000040" LANG="en-US" DIR="LTR">
<br><font face="Verdana" size=$fontsz>
$serverid $(date)
</font><br><br>
<font face="Verdana" size=$hfontsz><caption> Machine</caption></font>
<table border="1" cellpadding="5" cellspacing="0">
<tr><td><font face=\"Courier New\" size=$fontsz>
EOF
echo "$(uname -mrs)<br>" >>$webpgnm
lsb_release -a |
sed '/No LSB/d' |
sed 's/Description:/<br>Description:/g' |
sed 's/Release:/<br>Release:/g' |
sed 's/Codename:/<br>Codename:/g' >>$webpgnm
varupt=${varupt//up/Up}
varupt=${varupt//load/Load}
# this works, but is a bit awkward
# awk -F '[ \t\n\v\r]' '{print "<br>"$2" "$3" "$4" "$5" "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15}' <<< $varupt >> $webpgnm
# this version is a bit simpler, though you have to use the {} around two digit parameters
# (the "<br>$2" is to exclude a space between the <br> and the parameter value)
set $varupt
echo "<br>$2" $3 $4 $5 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} >>$webpgnm
cat >>$webpgnm <<-EOF
</font></td></tr></table><br>
</font></td></tr></table><br>
</body></html>"
EOF
exit 0
This eliminates the scratch file you were creating in /etc (bad place - /etc is for configuration files)
It also eliminates the HTML errors.
I believe the piped sequence of sed commands can also be eliminated, but will admit the sequence is simpler to debug and read.
I think there is a better way to handle the $varupt stuff. This just seems a bit awkward. But you can't beat what really works.
BTW, if you are going to use variables to hold file names... it is clearer to put the entire path in the variable too. It would eliminate multiple substitutions later on.
One final thing... This script is most likely being run as root. This means that the output file is USUALLY owned by root and with roots permissions, and security label. This shouldn't be a problem once the file is created and given the correct ownership/permissions/security label (RH and Fedora servers). The script preserves that when run by root as it only truncates the file at the beginning, then appends to it.