pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
paging
2+ messages / 2 participants
[nested] [flat]

* paging
@ 2001-03-26 18:04  A. Van Hook <hook@kcp.com>
  0 siblings, 1 reply; 2+ messages in thread

From: A. Van Hook @ 2001-03-26 18:04 UTC (permalink / raw)
  To: pgsql-sql

I have  a simple script to automate sql statements:  q " select * from
tablename"  where q is an alias to echo "$@ ;  " | psql imdb

Turning on security breaks this script since is need s password.

    the new one works a before: q "select *..." passwd where q is now
an expect script:
#!/usr/bin/expect

set query [lindex $argv 0]
set query [lindex $argv 1]

spawn psql imdb -U hook -n
          expect "Password: ";
          send   "$passwd\n ";
          expect "imdb=# ";
          send   "$query;\r";
          expect "imdb=# ";
          send   "\q;\r";

The problem is that long query returns  invoke the paging option  so you
can scroll a page a time. Paging doesn't work  properly within the
script and even if it did , I would have to disable it in order to
redirect the output to a file or a pipe.

    I can't  find any info in the docs. Can some one point me  in the
right direction....


thanks




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: paging
@ 2001-03-26 18:57  Peter Eisentraut <peter_e@gmx.net>
  parent: A. Van Hook <hook@kcp.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2001-03-26 18:57 UTC (permalink / raw)
  To: A. Van Hook <hook@kcp.com>; +Cc: pgsql-sql

A. Van Hook writes:

> #!/usr/bin/expect
>
> set query [lindex $argv 0]
> set query [lindex $argv 1]
>
> spawn psql imdb -U hook -n
>           expect "Password: ";
>           send   "$passwd\n ";
>           expect "imdb=# ";
>           send   "$query;\r";
>           expect "imdb=# ";
>           send   "\q;\r";
>
> The problem is that long query returns  invoke the paging option  so you
> can scroll a page a time. Paging doesn't work  properly within the
> script and even if it did , I would have to disable it in order to
> redirect the output to a file or a pipe.

Try psql -P pager to turn the pager off.  Also you can probably use

export PGPASSWORD=xyz
psql ...

to skip the password probe.

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-03-26 18:57 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-26 18:04 paging A. Van Hook <hook@kcp.com>
2001-03-26 18:57 ` Peter Eisentraut <peter_e@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox