Re: Variable for Filename ISQL
Posted in 1994
Alastair J. Small (asmall2@duquesne.ie) wrote: : Hi there, : Hopefully someone can give me some help on this. I'm using ACE ReportWriter : to generate some ASCII files for importing into another system. I've set it : up to prompt for some variables depending on what is needed, and would like : also to either prompt for the output filename, or combine the variables : obtained to a string representing what the output file contains. Here's something I wrote a while back for the same reasons: # ------------------------------ # File: pipe2file # Version: 1.2 # Last Modified: 93/01/25 09:24:24 # @(#)pipe2file 1.2 # ------------------------------ # # pipe2file - prompt user to input a filename, and take what's in stdin and # write it to the file. # NOTE: This script is used for outputing Informix ACE reports to USER # SPECIFIED filenames. Informix does not allow users to specify # the output file interactively! # But it does allow a program to be piped the output. So, this # cute little script is the "program" which receives the INFORMIX # report and will then write it out to the file the user specifies. # IFS=' ' # Just a newline in the quotes - used for preserving leading whitespaces ok=n ans=o while [ $ok = n ] do echo "Where to output to> \\c" >/dev/tty read FILE </dev/tty if [ -f $FILE ] then echo "$FILE exists: (o)verwrite, (a)ppend, <cr> ask filename again?\\c" >/dev/tty read ans </dev/tty if [ .$ans = .o ] then ok=y cat /dev/null >$FILE elif [ .$ans = .a ] then ok=y fi else ok=y fi if [ $ok = y ] then echo outputting to $FILE >/dev/tty fi done while read line do echo "$line" >>$FILE if [ $? != 0 ] then exit fi done -- *--------------------------------------------------------------------------* * Ronald R. Larson * * Staff Engineer * * Harris Corporation Phone: (407) 242-5578 * * Controls Division Fax: (407) 242-4268 * * P.O. Box 430, MS 205 internet: rrl@ccd.harris.com * * Melbourne, FL 32902-0430 EPRInet: UA4N311 * *--------------------------------------------------------------------------*