Re: using the output of a sql statement in a shell script
Posted in 1998
josephatlanta@my-dejanews.com wrote:
> Is there a SQL statement that can give me the output of the switches without
> the "switch_id" and/or the "14 row(s) retreived." text?
Yes, there is (almost). Use the "OUTPUT" command with the "WITHOUT HEADINGS"
option. And redirect "stderr" to "/dev/null" since the "xx rows retrieved"
goes to stderr.
> response=`
> {
> dbaccess ${dbname} - <<EOF
> select switch_id from switches where switch_id4 = "M1"> EOF
> } 2>&1 `
>
> echo $response
>
> #switch_id RIM 2JY 2JV CLX 2OR ASC AU1 AUP BCS AUA AUO BOY BHW 2M8 14 row(s)
> retrieved.
response=`
{
dbaccess ${dbname} - <<EOF
output to pipe cat without headings
select switch_id from switches where switch_id4 = "M1"EOF
} 2>/dev/null `
HTH, Richard
--
+--------------------------+------------------------------------------+
| Dr. Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de |
| EDV-Gruppe Anaesthesie | Tel : +49-89-7095-3413 |
| Klinikum Grosshadern | FAX : +49-89-7095-8886 |
| 81366 Munich, Germany | GSM : +49-172-8933578 |
+--------------------------+------------------------------------------+