#!/bin/csh
# This script reads chemical names from the file named in the first position of its
# argument list, requests information on these chemicals from webbook.nist.gov using lynx,
# and saves the results to the file named in the second position of its argument list.
# E.g. use getcheminfo2 infile outfile

set tmp = tmpOKtoDelete
echo Chemical CAS\# > $2
foreach chemical (`cat $1`)
  echo Looking up $chemical
  lynx -source "http://webbook.nist.gov/cgi/cbook.cgi?Name=$chemical&Units=SI" | grep Registry > $tmp
  echo $chemical `sed -e 's|<li><strong>CAS Registry Number:</strong> ||' -e 's|</li>||' $tmp` >> $2
end
rm $tmp
