Solved Shell script to access Postgre Db and write output to file

September 27, 2013 at 00:59:07
Specs: Solaris
Hi Experts,

I would like to seek your assistance in creating a shell script that will access the postgre DB from Solaris OS and will write the output to a file.

I am most interested in knowing the connect string of postgre DB and how to write the result of query into a certain file.

Any input is highly appreciated.

Best Regards,

See More: Shell script to access Postgre Db and write output to file

Report •

October 6, 2013 at 21:44:52
✔ Best Answer
You can not connect directly to a database with a *nix shell script. But each commercial database has a user interface for executing data management commands. An interface's output can be captured inside a shell script:

Oracle uses sqlplus. Here is an example:

Informix uses dbaccess or isql. Here is an example:

PostregSQL uses psql: Here is an example:

Of course, a modern scripting language like Perl or Python support libraries that support database connections. This describes the Perl DBI:

Let me know if you have any specific questions.


message edited by nails

Report •
Related Solutions

Ask Question