[NTLUG:Discuss] Help with script
Eric Schnoebelen
eric at cirr.com
Thu Mar 18 13:23:14 CDT 2010
Leroy Tennison writes:
- I'm attempting to "wrap" HTML around a script's output in order to make
- the output "pretty" but I also need to output the "real" commands in the
- script (but not the ones doing the "beautification"). My current
- attempt looks like:
-
- function pretty {
- echo "<tr><td>" $@ "</td></tr><tr><td>"
- $@
- echo "</td></tr>"
- }
Change to:
function pretty {
echo "<tr><td>" "$@" "</td></tr></tr><td>"
eval "$@"
echo "</td></tr>
}
eval has the effect of creating a shell environment for the
command to be interpreted and executed in. And providing the
output and status back to the calling environment.
- It seems that $@ has to be an executable program, nothing else works.
- Executing the script with -v or -x doesn't add much except parts of the
- command are being quoted. Any one know how to solve this problem? Much
- thanks.
--
Eric Schnoebelen eric at cirr.com http://www.cirr.com
"As far as I know, there will be no more unplanned surprises this week."
More information about the Discuss
mailing list