From: | "Jim Wilson" <jimw(at)kelcomaine(dot)com> |
---|---|
To: | <psql-general(at)postgresql(dot)org> |
Subject: | Re: "echo"ing a psql command in a bash script |
Date: | 2004-09-03 14:39:05 |
Message-ID: | twig.1094222345.61185@kelcomaine.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ennio-Sr said:
> (once for all):
> cmnd=echo psql mydb -x -c "SELECT * FROM tb_nm WHERE $col_nm LIKE '%$k_r%'"
That will be executed immediately, and give you an error.
> (in each <case n>):
> col_nm="....."
> echo $cmnd
I'm surprised you get anything. AFAIK this should parse the files in your
directory into column names. Maybe you are doing something slightly different?
Rather than setting the $cmnd variable, try using something like this:
echo mydb -x -c \"SELECT "*" FROM tb_nm WHERE $col_nm LIKE \'%$k_r%\'\" |
xargs psql
I'm not sure where you are storing your column names, but if you can pipe it
as a list into the above you won't need to rum a loop in your script. There
are a thousand ways to do this, but most important is remember to quote the
"*" so the shell doesn't parse it. BTW You did not say, so I'm also assuming
you are using "bash" or "sh" since that's what this looks like. :-)
Best,
Jim
From | Date | Subject | |
---|---|---|---|
Next Message | Mike | 2004-09-03 14:56:16 | Re: pgAccess via ssh? |
Previous Message | Shelby Cain | 2004-09-03 14:11:24 | pl/pgsql exceptions |