"echo"ing a psql command in a bash script

Поиск
Список
Период
Сортировка
От Ennio-Sr
Тема "echo"ing a psql command in a bash script
Дата
Msg-id 20040902205414.GA11554@deby.ei.hnet
обсуждение исходный текст
Ответы Re: "echo"ing a psql command in a bash script  ("Jim Wilson" <jimw@kelcomaine.com>)
Список pgsql-general
Hi all!
I'm writing a script that presents the user with a numbered lines
menu, each line corresponding to a <case n> which executes a psql
command. As the psql-commands are very similar to each other (all of
them have the structure:

1.- psql mydb -x -c "SELECT * FROM tb_nm WHERE col_nm LIKE '%$k_r%'"  )

I thought it was possible to shorten it, initializing a str with said
command at the beginning of the script and limiting the various case
lines to defining the col_nm and the $k_r to be searched, i.e.:

2. -
(once for all):
cmnd=echo psql mydb -x -c "SELECT * FROM tb_nm WHERE $col_nm LIKE '%$k_r%'"

(in each <case n>):
col_nm="....."
echo $cmnd
---------------------------
The point is that:
when I test command "1", the query result appears immediately on the
screen and disappears (leaving room to the script menu), when I press
"q"; i.e., the environment remains that of psql until I press "q", which
seems to be a correct behaviour;

whereas, testing command "2", first appears the menu again (as if the
query had been unsuccessfull) and then (after pressing Enter - which
normally would cause exiting the script) the query result shows.

Could somebody throw some light on this issue?
Thanks for your attention.
    Ennio.

--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.     \\?//
 Fa' qualche cosa di cui non sei capace!"   (diceva Henry Miller) ]     (°|°)
[Why to use Win$ozz (I say) if ... "even a fool can do that.             )=(
 Do something you aren't good at!" (used to say Henry Miller) ]

В списке pgsql-general по дате отправления:

Предыдущее
От: Paul Tillotson
Дата:
Сообщение: postgres "on in the internet"
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: postgres "on in the internet"