pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
sql copy does not work
4+ messages / 3 participants
[nested] [flat]

* sql copy does not work
@ 2006-03-02 14:17 Aniko.Badzong@swisscom.com
  2006-03-02 14:43 ` Re: sql copy does not work Guido Barosio <gbarosio@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Aniko.Badzong@swisscom.com @ 2006-03-02 14:17 UTC (permalink / raw)
  To: pgsql-admin

Hi 

I have a problem with the copy command. I need to write a Perl script
where I copy the log files into the database.
If I use the copy following syntax in shell script it works, but I need
to use it in Perl.

In shell script look like this and it works.
su - postgres -c "echo "\""copy test from '/data/20060227.out';"\"" |
psql imsdb"

this is how it looks like in Perl:
system ("su - postgres -c \"echo \"\"\"copy test from
\'/data/log/20060115.out\'\;\"\"\" | psql imsdb\""); 

I escape always the " but then I get the following error.
copy
sh:  | psql imsdb: not found


If I try the other way around there is always an error that role c does
not exist....
system ("su - postgres -c \"psql imsdb -c \"copy mss6n from
'/data/20060227.out'\;\"");
psql: warning: extra command-line argument "copy" ignored
psql: FATAL:  role "-c" does not exist

If I try to use copy with the -c option I always get an error that role
-c does not exist.
Anyone has any idea why?
I was searching in the knowledge database and docs for this error but I
can not find anything.


Many thanks
Aniko

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

* Re: sql copy does not work
  2006-03-02 14:17 sql copy does not work Aniko.Badzong@swisscom.com
@ 2006-03-02 14:43 ` Guido Barosio <gbarosio@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Guido Barosio @ 2006-03-02 14:43 UTC (permalink / raw)
  To: Aniko.Badzong@swisscom.com <Aniko.Badzong@swisscom.com>; +Cc: pgsql-admin

Not the real solution for your problem, but if you are already using perl,
then why not give a try to Pg?

http://search.cpan.org/search?query=Pg&mode=all

Regards,
G.-

On 3/2/06, Aniko.Badzong@swisscom.com <Aniko.Badzong@swisscom.com> wrote:
>
> Hi
>
> I have a problem with the copy command. I need to write a Perl script
> where I copy the log files into the database.
> If I use the copy following syntax in shell script it works, but I need to
> use it in Perl.
>
> In shell script look like this and it works.
> *su - postgres -c "echo "\""copy test from '/data/20060227.out';"\"" |
> psql imsdb"*
>
> this is how it looks like in Perl:
> *system ("su - postgres -c \"echo \"\"\"copy test from
> \'/data/log/20060115.out\'\;\"\"\" | psql imsdb\""); *
>
> I escape always the " but then I get the following error.
> copy
> sh:  | psql imsdb: not found
>
> If I try the other way around there is always an error that role c does
> not exist....
> *system ("su - postgres -c \"psql imsdb -c \"copy mss6n from
> '/data/20060227.out'\;\"");*
> psql: warning: extra command-line argument "copy" ignored
> psql: FATAL:  role "-c" does not exist
>
> If I try to use copy with the -c option I always get an error that role -c
> does not exist.
> Anyone has any idea why?
> I was searching in the knowledge database and docs for this error but I
> can not find anything.
>
> Many thanks
> Aniko
>



--
/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------

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

* Re: sql copy does not work
@ 2006-03-02 14:48 Jason Minion <jason.minion@sigler.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Jason Minion @ 2006-03-02 14:48 UTC (permalink / raw)
  To: Aniko.Badzong@swisscom.com; pgsql-admin

You probably need to add escaped slashes into your perl string to escape
the quotes on the command line. Maybe try:
 
system ("su - postgres -c \"echo \"\\\"\"copy test from
\'/data/log/20060115.out\'\;\"\\\"\" | psql imsdb\""); 

Jason Minion 



________________________________

From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of
Aniko.Badzong@swisscom.com
Sent: Thursday, March 02, 2006 8:17 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] sql copy does not work



Hi 

I have a problem with the copy command. I need to write a Perl script
where I copy the log files into the database. 
If I use the copy following syntax in shell script it works, but I need
to use it in Perl. 

In shell script look like this and it works. 
su - postgres -c "echo "\""copy test from '/data/20060227.out';"\"" |
psql imsdb" 

this is how it looks like in Perl: 
system ("su - postgres -c \"echo \"\"\"copy test from
\'/data/log/20060115.out\'\;\"\"\" | psql imsdb\""); 

I escape always the " but then I get the following error. 
copy 
sh:  | psql imsdb: not found 


If I try the other way around there is always an error that role c does
not exist.... 
system ("su - postgres -c \"psql imsdb -c \"copy mss6n from
'/data/20060227.out'\;\""); 
psql: warning: extra command-line argument "copy" ignored 
psql: FATAL:  role "-c" does not exist 

If I try to use copy with the -c option I always get an error that role
-c does not exist. 
Anyone has any idea why? 
I was searching in the knowledge database and docs for this error but I
can not find anything. 


Many thanks 
Aniko 

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

* Re: sql copy does not work
@ 2006-03-02 14:55 Aniko.Badzong@swisscom.com
  0 siblings, 0 replies; 4+ messages in thread

From: Aniko.Badzong@swisscom.com @ 2006-03-02 14:55 UTC (permalink / raw)
  To: jason.minion@sigler.com; pgsql-admin

Hi Jason
 
You are a genius:-)) It worked....
I am fighting with it since a week...
Thank you so much.
 
Regards
Aniko

________________________________

From: Jason Minion [mailto:jason.minion@sigler.com] 
Sent: Thursday, March 02, 2006 3:49 PM
To: Badzong Aniko, FX-IT-SDY-CIA-MSG; pgsql-admin@postgresql.org
Subject: RE: [ADMIN] sql copy does not work


You probably need to add escaped slashes into your perl string to escape
the quotes on the command line. Maybe try:
 
system ("su - postgres -c \"echo \"\\\"\"copy test from
\'/data/log/20060115.out\'\;\"\\\"\" | psql imsdb\""); 

Jason Minion 



________________________________

From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of
Aniko.Badzong@swisscom.com
Sent: Thursday, March 02, 2006 8:17 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] sql copy does not work



Hi 

I have a problem with the copy command. I need to write a Perl script
where I copy the log files into the database. 
If I use the copy following syntax in shell script it works, but I need
to use it in Perl. 

In shell script look like this and it works. 
su - postgres -c "echo "\""copy test from '/data/20060227.out';"\"" |
psql imsdb" 

this is how it looks like in Perl: 
system ("su - postgres -c \"echo \"\"\"copy test from
\'/data/log/20060115.out\'\;\"\"\" | psql imsdb\""); 

I escape always the " but then I get the following error. 
copy 
sh:  | psql imsdb: not found 


If I try the other way around there is always an error that role c does
not exist.... 
system ("su - postgres -c \"psql imsdb -c \"copy mss6n from
'/data/20060227.out'\;\""); 
psql: warning: extra command-line argument "copy" ignored 
psql: FATAL:  role "-c" does not exist 

If I try to use copy with the -c option I always get an error that role
-c does not exist. 
Anyone has any idea why? 
I was searching in the knowledge database and docs for this error but I
can not find anything. 


Many thanks 
Aniko 

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


end of thread, other threads:[~2006-03-02 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-03-02 14:17 sql copy does not work Aniko.Badzong@swisscom.com
2006-03-02 14:43 ` Guido Barosio <gbarosio@gmail.com>
2006-03-02 14:48 Re: sql copy does not work Jason Minion <jason.minion@sigler.com>
2006-03-02 14:55 Re: sql copy does not work Aniko.Badzong@swisscom.com

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