daveh@marob.MASA.COM (Dave Hammond) (08/02/88)
I would like to redirect the standard output of Informix 2.1 SQL from the isql command line directly, e.g. something on the order of: select * from table [ > save_file ] or: select * from table [ | command ] I know I can do this from within a shell script and redirect output that way, but this involves reloading and initialising isql for each statement to be redirected. About the only thing I've come up with is tee'ing a log file, editing the log, etc (which s[t,u].*ks :-) Any suggestions ? Dave Hammond /dsix2!daveh UUCP: {uunet | rutgers | spl1 | ...}!{masa.com | hombre}!< DOMAIN: dsix2!daveh@masa.com \marob!daveh ---------------------------------------------------------------------------- -- Dave Hammond /dsix2!daveh UUCP: {uunet | rutgers | spl1 | ...}!{masa.com | hombre}!< DOMAIN: dsix2!daveh@masa.com \marob!daveh -------------------------------------------------------------------------
aland@infmx.UUCP (Dr. Scump) (08/02/88)
In article <346@marob.MASA.COM>, daveh@marob.MASA.COM (Dave Hammond) writes: > > I would like to redirect the standard output of Informix 2.1 SQL from > the isql command line directly, e.g. something on the order of: > > select * from table [ > save_file ] or: > select * from table [ | command ] > > I know I can do this from within a shell script and redirect output > that way, but this involves reloading and initialising isql for each > statement to be redirected. About the only thing I've come up with is > tee'ing a log file, editing the log, etc (which s[t,u].*ks :-) > > Any suggestions ? > Dave Hammond /dsix2!daveh > (dual .sig lines deleted :-]) Ouch. Messy. But, there's already an *easy* way! In the Query-Langauge menu, the Output option allows you to send the query results to a new file, append to an existing file, send to the printer, or send to any other pipe. Just type in your RDSQL statement (or "Choose" it via the menu if it is a canned script), and instead of choosing Run, select Output (type "O" or use the ring menu). You will get another menu to select Newfile/Appendfile/Printer/ To-pipe -- just follow the prompts. (the Printer option sends to whatever printer is specified in the DBPRINT env variable if present, otherwise a regular "lp" or "lpr" pipe is used...) See page 7-51 of the User Guide (version 2.10 Rev A) for more info. OR... if you are just running from the command line (not using the menus)... the output will go to STDOUT, errors to STDERR. Therefore, to run the sql script "foo.sql" against database "yomama" and send the output to the printer... isql yomama foo | lpr OR, if you have a "DATABASE yomama" statement in the "foo.sql" script already... isql - foo | lpr This is the "old" (ISQL 2.0) format of the run-query-language-from-the- command-line capability, but it still works (and is easier to use than the {isql yomama -qcr foo} format). The "old" format was inadvertently left out of the 2.10 manual... OR, if you want to route output from each statement separately... You can prefix any select statement with an OUTPUT clause, e.g. OUTPUT TO {filename | PIPE "pgmname"} SELECT ... See page 2-117 of the Reference Manual for this one. Enough choices? "Don't worry... be happy..." -- Alan S. Denney | Informix Software, Inc. | {pyramid|uunet}!infmx!aland Disclaimer: These opinions are mine alone. If I am caught or killed, the secretary will disavow any knowledge of my actions. Santos' 4th Law: "Anything worth fighting for is worth fighting *dirty* for"