Reputation: 320
debian8@debian:~$ ls -al /home/debian8/.mozilla/firefox/3usaclqf.default/lock
lrwxrwxrwx 1 debian8 debian8 15 Jun 19 18:58 /home/debian8/.mozilla/firefox/3usaclqf.default/lock -> 127.0.1.1:+2815
The file /home/debian8/.mozilla/firefox/3usaclqf.default/lock
is a link.
debian8@debian:~$ python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
>>> import os
>>> file1="/tmp/.X0-lock"
>>> print(os.stat(file1))
os.stat_result(st_mode=33060, st_ino=8126472, st_dev=2050, st_nlink=1, st_uid=0, st_gid=0, st_size=11, st_atime=1497877067, st_mtime=1497868886, st_ctime=1497868886)
>>> file2="/home/debian8/.mozilla/firefox/3usaclqf.default/lock"
>>> print(os.stat(file2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/home/debian8/.mozilla/firefox/3usaclqf.default/lock'
Why os.stat
can't get infos on file2?
Upvotes: 0
Views: 1365
Reputation: 50731
Does the file it is linked to exist? os.stat() follows symlinks. If you want to stat the link file, you need os.lstat()
Upvotes: 3
Reputation: 43
Maybe you don't have permission to open this file.try sudo chmod 777 /home/debian8/.mozilla/firefox/3usaclqf.default/lock
Upvotes: -1