include shell commands in query

Started by Sebastian Kniatalmost 23 years ago4 messagesgeneral
Jump to latest
#1Sebastian Kniat
sebkniat@wp.pl

Hello,
is posible to include shell commands, like ping, into query?
e.x.
select current_timestamp, "ping IP_adress" into table table_name

With best regards
Sebastian Kniat

---------------------------------------------------
Szukasz wyjazdu wakacyjnego? Sprawdďż˝ nasze oferty!
Nowy serwis w WP http://oferty.wp.pl/wakacje.html

#2Bruno Wolff III
bruno@wolff.to
In reply to: Sebastian Kniat (#1)
Re: include shell commands in query

On Fri, Jun 13, 2003 at 21:56:23 +0200,
Sebastian Kniat <sebkniat@wp.pl> wrote:

Hello,
is posible to include shell commands, like ping, into query?
e.x.
select current_timestamp, "ping IP_adress" into table table_name

You could write a function to do this, but it probably isn't a good idea.
Usually you want something external to the database to run commands based
on information stored in the database.

#3Bruce Momjian
bruce@momjian.us
In reply to: Sebastian Kniat (#1)
Re: include shell commands in query

Sebastian Kniat wrote:

Hello,
is posible to include shell commands, like ping, into query?
e.x.
select current_timestamp, "ping IP_adress" into table table_name

You can do it in psql:

test=> \set x '\'' `pwd` '\''
test=> select :x;
?column?
---------------------------
/usr/var/local/users/root
(1 row)

See the psql manual page for more information.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#4Dennis Gearon
gearond@cvc.net
In reply to: Sebastian Kniat (#1)
Re: include shell commands in query

Sure, it goes in like a text string. Now, if you want it to execute while in the query and NOT go into the database, I would doubt that you could have that.

Sebastian Kniat wrote:

Show quoted text

Hello,
is posible to include shell commands, like ping, into query?
e.x.
select current_timestamp, "ping IP_adress" into table table_name

With best regards
Sebastian Kniat

---------------------------------------------------
Szukasz wyjazdu wakacyjnego? Sprawdďż˝ nasze oferty!
Nowy serwis w WP http://oferty.wp.pl/wakacje.html

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend