I'd use Perl for this, though there are other languages for the job.
eg.
Code:
#!/bin/sh
USERID=
PWD=
PWD1=
dir=`pwd`
ip=
intface=
DATE=`date +'%m%d'`
Time=`date +'%H%M'`
(echo "$USERID";\
echo "$PWD";\
echo "en";\
echo "$PWD1";\
echo "sh ip cache flow";\
echo "q";\
echo "sh ip pat does not understand this router";\
echo "q";\
sleep 30 )| telnet $ip > perl -e '<STDIN>;open FILEONE, > $dir/info$ip$DATE$Time.txt; print FILEONE, $_; <STDIN>;open FILEONE, > $dir/info$ip$DATE$Time.txt2; print FILEONE, $_; <STDIN>;open FILEONE, > $dir/info$ip$DATE$Time.txt3; print FILEONE, $_; '
The Perl bit is far too long and could probably be condensed into some kind of loop. I've printed a line to each file, those files having the same name but with a number appended. Watch the syntax errors!
-pcweirdo.