Tris Orendorff said:
f> Hi,
Hi,
Use the ` feature of most shells to run a program and use its standard output as input on a command line:
xxx=`java HelloWorldApp.class`
echo $xxx
Hello, World!
Peace.
<output>
$ xxx=`java me`
$ echo $xxx
Peace
$
</output>
Those quotes are backquotes, which are located near the number one
on my keyboard.
You can use this technique with other programs that output their
data to standard out, such as lynx. In addition, the pipe
operator may be used.
<code>
#!/usr/bin/ksh
tableCount=0
trCount=0
endtrCount=0
readData=0
no_reg_string="<td align=\"center\" bgcolor=\"#FFFFFF\" colspan=\"2\"><IMG"
tableElement="<table"
rowElement="<tr"
endrowElement="</tr"
raw_data=`lynx -source -dump
http://weatheroffice.ec.gc.ca/forecast/city_e.html?yyz`
echo "content-type: text/html"
echo
tableThere=`echo "$raw_data" | grep "$no_reg_string"`
#<td align="center" bgcolor="#FFFFFF" colspan="2">
#<IMG src="/weathericons/16.gif" border="0"
#width="60" height="51" alt="Light Snow"></td>
#remove everything up to first >
#remove </td>
#surround with base tag
#backslash use to escape >
no_left=${tableThere#*\>}
no_right=${no_left%\</td\>}
echo "<base href=\"
http://weatheroffice.ec.gc.ca\">$no_right</base>"
</code>
<output>
content-type: text/html
<base href="
http://weatheroffice.ec.gc.ca"><IMG src="/weathericons/31.gif" borde
r="0" width="60" height="51" alt="Mainly Clear"></base>
</output>
Have a good day.