Permissions to append to a file in python?

Question

I am having trouble understanding why I am unable to append to a file in python3 (3.2.3). I create these files in a shared folder but I am unable to append to them. There are no issues with files in my home folder. The shared folder permissions are:

drwxrwxrwx  2 nobody   share       65536 2017-01-01 22:16 Pictures

I am in the 'share' group which has all the permissions:

groups alex
share www-data

I can create the file:

>>> testFile=open ('VID_2.mp4', 'wb')
>>> testFile.close()

But I cannot append to it:

>>> testFile=open ('VID_2.mp4', 'ab')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'VID_2.mp4'

I checked the file permissions and, from my understanding, I should be able to append to that file:

ls -l
-rw-rw-rw- 1 alex share 0 2017-01-01 22:40 VID_2.mp4    

So I am baffled as to why the permission to append is denied, and what permission would be required to allow the append.

UPDATE: It seems the issue is not with the python script since I get the same permission error if I use echo:

touch myfile.txt
echo 1 > myfile.txt
echo 2 >> myfile.txt
-bash: myfile.txt Permission denied
ls -l myfile.txt
-rw-rw-rw- 1 alex share 2 2017-01-03 09:44 myfile.txt

UPDATE 2:

These folders are under a regular mount (/DataVolume):

/dev/sda4 on /DataVolume type ext4 (rw,noatime,nodiratime)
/DataVolume/cache on /CacheVolume type none (rw,bind)
/DataVolume/shares on /shares type none (rw,bind)
/DataVolume/shares on /nfs type none (rw,bind)

cat /proc/mounts
/dev/sda4 /DataVolume ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0
/dev/sda4 /CacheVolume ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0
/dev/sda4 /shares ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0
/dev/sda4 /nfs ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0

I can append to files in /DataVolume/home/alex but not to files under /DataVolume/shares:

ls -l /DataVolume/
drwxrwxr-x  4 root root      65536 2013-11-14 21:15 home
drwxrwxr-x  7 root share     65536 2017-01-04 10:16 shares
ls -l /DataVolume/home/
drwxr-xr-x 7 alex   share 65536 2017-01-01 22:24 alex
ls -l /DataVolume/home/alex
-rw-rw-rw- 1 alex share     4 2017-01-04 10:20 test.txt
ls -l /DataVolume/shares/
drwxrwxrw-  2 alex   share 65536 2017-01-04 10:23 test

Show source
| python   | linux   | python-3.x   | unix   | file-permissions   2017-01-02 04:01 0 Answers

Answers to Permissions to append to a file in python? ( 0 )

Leave a reply to - Permissions to append to a file in python?

◀ Go back