with latest version 9.3 you can use a copy from with a programm as argument.You can use the unix | pipe for most of the stuff.If you have an older version you can use the mkfifo command to "trick" postgres into believing he will copy from a file.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных