Thread: COPY failure on directory I own

COPY failure on directory I own

From
Rich Shepard
Date:
   I need to understand why this command fails:

nevada=# copy statdata to
'/home/rshepard/projects/nevada/queenstake/stats/chem.csv' with delimiter '|'
null as 'NA' CSV HEADER;
ERROR:  could not open file
"/home/rshepard/projects/nevada/queenstake/stats/chem.csv" for writing:
Permission denied

   The permissions on that directory are 755 and it's owned by me. Since I
have no problems writing other files to that directory I must have the
command syntax incorrect but I don't see where.

Rich

Re: COPY failure on directory I own

From
Scott Ribe
Date:
On Aug 30, 2011, at 11:14 AM, Rich Shepard wrote:

> The permissions on that directory are 755 and it's owned by me. Since I
> have no problems writing other files to that directory I must have the
> command syntax incorrect but I don't see where.

Where is the server and where are you? You are issuing a command to the server to create a file at that path on the
server.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





Re: COPY failure on directory I own

From
Scott Mead
Date:


On Tue, Aug 30, 2011 at 1:20 PM, Scott Ribe <scott_ribe@elevated-dev.com> wrote:
On Aug 30, 2011, at 11:14 AM, Rich Shepard wrote:

> The permissions on that directory are 755 and it's owned by me. Since I
> have no problems writing other files to that directory I must have the
> command syntax incorrect but I don't see where.

In this case, it's not about YOU and your permissions, it's about the server.  The COPY command writes data as the 'postgres' operating system user (or whichever user owns the postgres backend process).

--Scott

 

Where is the server and where are you? You are issuing a command to the server to create a file at that path on the server.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: COPY failure on directory I own

From
Rich Shepard
Date:
On Tue, 30 Aug 2011, Scott Ribe wrote:

> Where is the server and where are you? You are issuing a command to the
> server to create a file at that path on the server.

   It's sitting right here next to my desk. That host is the network server
and my workstation. Yes, my home directory (and all other directories) are
on that host.

Rich

Re: COPY failure on directory I own

From
Rich Shepard
Date:
On Tue, 30 Aug 2011, Scott Mead wrote:

> In this case, it's not about YOU and your permissions, it's about the
> server. The COPY command writes data as the 'postgres' operating system
> user (or whichever user owns the postgres backend process).

Scott,

   Ah so. User 'postgres' is in the same group ('users') as I am, so I need
to change the perms on the data directory to 775 to give postgres write
access.

Thanks,

Rich

Re: COPY failure on directory I own [FIXED]

From
Rich Shepard
Date:
On Tue, 30 Aug 2011, Rich Shepard wrote:

>  Ah so. User 'postgres' is in the same group ('users') as I am, so I need
> to change the perms on the data directory to 775 to give postgres write
> access.

   That did the trick. Thanks for the lesson, Scott.

Rich

Re: COPY failure on directory I own

From
Craig Ringer
Date:
On 31/08/2011 1:34 AM, Rich Shepard wrote:
> On Tue, 30 Aug 2011, Scott Mead wrote:
>
>> In this case, it's not about YOU and your permissions, it's about the
>> server. The COPY command writes data as the 'postgres' operating system
>> user (or whichever user owns the postgres backend process).
>
> Scott,
>
> Ah so. User 'postgres' is in the same group ('users') as I am, so I need
> to change the perms on the data directory to 775 to give postgres write
> access.

Yeah, or use the client/server copy protocol via psql's \copy command.

--
Craig Ringer


Re: COPY failure on directory I own

From
Rich Shepard
Date:
On Wed, 31 Aug 2011, Craig Ringer wrote:

> Yeah, or use the client/server copy protocol via psql's \copy command.

Craig,

   I was aware there was a back-slash version but did not recall when its use
is appropriate nor just how to use it.

Thanks,

Rich