Eliminate output from vsql in batch

Moderator: NorbertKrupa

Post Reply
billykopecki
Beginner
Beginner
Posts: 42
Joined: Thu Apr 19, 2012 9:03 pm

Eliminate output from vsql in batch

Post by billykopecki » Fri May 25, 2012 3:28 pm

Hey,

I have a bunch of vsql commands running scripts in batch mode and I would prefer that there be no out put from the vsql statements.

For instance, for this simple example:

Code: Select all

v1_server$ vsql -c "select count(*) from sessions"
 count
-------
     1
(1 row)
I don't want to see the results:

Code: Select all

 count
-------
     1
Is there a flag or switch I can use when running vsql to not show any output?

Thank you

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Eliminate output from vsql in batch

Post by id10t » Sun May 27, 2012 7:32 am

I don't know how to do the output as you want, but look at option "\o" and send query output to file (/dev/null for example):

Code: Select all

dbadmin=> select * from test_table;
 id | name |      value       
----+------+------------------
  5 | foo  | 5.65665282582291
  6 | bar  | 5.42883523318981
  7 | baz  | 4.64158883361278
(3 rows)

Code: Select all

dbadmin=> \timing
Timing is on.
dbadmin=> \o /dev/null
dbadmin=> select * from test_table;
Time: First fetch (3 rows): 5.529 ms. All rows formatted: 5.585 ms

Code: Select all

dbadmin@suse:/tmp> vsql -c "select * from test_table"
 id | name |      value       
----+------+------------------
  5 | foo  | 5.65665282582291
  6 | bar  | 5.42883523318981
  7 | baz  | 4.64158883361278
(3 rows)

Code: Select all

dbadmin@suse:/tmp> echo -e  "\\\timing\n\o /dev/null\nselect * from test_table;" | vsql
Timing is on.
Time: First fetch (3 rows): 5.902 ms. All rows formatted: 5.985 ms

jpcavanaugh
Intermediate
Intermediate
Posts: 149
Joined: Mon Apr 30, 2012 10:04 pm
Location: New York
Contact:

Re: Eliminate output from vsql in batch

Post by jpcavanaugh » Mon May 28, 2012 5:05 pm

vsql -o /dev/null -c "select count(*) from sessions"

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Eliminate output from vsql in batch

Post by id10t » Mon May 28, 2012 6:32 pm

@juniorfoo your solution always will be empty ;)

PS :mrgreen: :mrgreen: :mrgreen:

Code: Select all

dbadmin@suse:~/temp> vsql -c "select count(*) from sessions" | head -3
 count 
-------
     2

Code: Select all

dbadmin=> select count(*) from system_tables \g | head -3
 count 
-------
    72
dbadmin=> 

User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

Re: Eliminate output from vsql in batch

Post by Julie » Tue May 29, 2012 3:06 pm

Cool! Thanks, guys. I was also looking at a way to do this.
Thanks,
Juliette

Post Reply

Return to “vSQL”