ubuntun 14.04, psql 無法使用 [論壇 - Ubuntu基本設定]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊



ubuntun 14.04, psql 無法使用
會員二級
註冊日期:
2008/5/5 8:18
所屬群組:
已註冊使用者
等級: 4
HP : 0 / 94
MP : 12 / 2648
EXP: 76
離線
postgres@ubuntu:~$ psql
Can't locate strict.pm: 拒絕不符權限的操作 at /usr/bin/psql line 19.
BEGIN failed--compilation aborted at /usr/bin/psql line 19.

9/2 13:40:02
應用擴展 工具箱
回覆: ubuntun 14.04, psql 無法使用
會員二級
註冊日期:
2008/5/5 8:18
所屬群組:
已註冊使用者
等級: 4
HP : 0 / 94
MP : 12 / 2648
EXP: 76
離線
updated !!!
查出來是因為perl的模組無法讀取
不過我用locate strtic.pm是可以找到檔案的位置

9/2 17:00:51
我的ubuntu,我的世界

Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
應用擴展 工具箱
回覆: ubuntun 14.04, psql 無法使用
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 33
HP : 161 / 806
MP : 508 / 13318
EXP: 24
離線
kikiyami 寫到:
postgres@ubuntu:~$ psql
Can't locate strict.pm: 拒絕不符權限的操作 at /usr/bin/psql line 19.
BEGIN failed--compilation aborted at /usr/bin/psql line 19.



kikiyami 寫到:
updated !!!
查出來是因為perl的模組無法讀取
不過我用locate strtic.pm是可以找到檔案的位置



不是很確定您發生這個狀況確切的成因是什麼?

以下提供我剛剛做的小實驗,紀錄一些操作步驟,供您參考。

不過我測試的環境是「Xubuntu 16.04 amd64 英文界面」。

================================================================================

## 探索步驟

執行


$ whereis psql



顯示


psql: /usr/bin/psql /usr/share/man/man1/psql.1.gz



執行


$ which psql



顯示


/usr/bin/psql



執行


$ file /usr/bin/psql



顯示


/usr/bin/psql: symbolic link to ../share/postgresql-common/pg_wrapper



執行


$ file /usr/share/postgresql-common/pg_wrapper



顯示


/usr/share/postgresql-common/pg_wrapper: a /usr/bin/perl -w script, ASCII text executable



執行


$ grep strict /usr/bin/psql -n



顯示


19:use strict;



執行


$ locate strict.pm



顯示


/usr/lib/x86_64-linux-gnu/perl-base/strict.pm
/usr/share/perl/5.22.1/strict.pm



執行


$ dpkg -S strict.pm



顯示


perl-modules-5.22: /usr/share/perl/5.22.1/strict.pm
perl-base: /usr/lib/x86_64-linux-gnu/perl-base/strict.pm



執行


$ apt-file search strict.pm



顯示


libperlio-utf8-strict-perl: /usr/lib/x86_64-linux-gnu/perl5/5.22/PerlIO/utf8_strict.pm
perl-base: /usr/lib/x86_64-linux-gnu/perl-base/strict.pm
perl-modules-5.22: /usr/share/perl/5.22.1/strict.pm




執行


$ ls -l /usr/share/perl/5.22.1/strict.pm



顯示


-rw-r--r-- 1 root root 1514 Mar 13 2016 /usr/share/perl/5.22.1/strict.pm



執行


$ ls /usr/lib/x86_64-linux-gnu/perl-base/strict.pm -l



顯示


-rw-r--r-- 1 root root 1514 Mar 13 2016 /usr/lib/x86_64-linux-gnu/perl-base/strict.pm




================================================================================

## 測試步驟

執行


$ sudo chmod -r /usr/share/perl/5.22/strict.pm



執行


$ ls -l /usr/share/perl/5.22/strict.pm



顯示


--w------- 1 root root 1514 Mar 13 2016 /usr/share/perl/5.22/strict.pm



執行


$ file /usr/share/perl/5.22/strict.pm



顯示


/usr/share/perl/5.22/strict.pm: regular file, no read permission



執行


$ cat /usr/share/perl/5.22/strict.pm



顯示


cat: /usr/share/perl/5.22/strict.pm: Permission denied



執行下面指令,產生一個測試檔「test.pl」。


cat > test.pl << EOF
#!/usr/bin/env perl

use strict;

EOF



上面的指令,就是產生一個檔案「test.pl」,內容如下


#!/usr/bin/env perl

use strict;



執行


$ chmod u+x test.pl



執行


$ ./test.pl



顯示


Can't locate strict.pm: /usr/share/perl/5.22/strict.pm: Permission denied at ./test.pl line 3.
BEGIN failed--compilation aborted at ./test.pl line 3.



執行


$ psql



顯示


Can't locate strict.pm: /usr/share/perl/5.22/strict.pm: Permission denied at /usr/bin/psql line 19.
BEGIN failed--compilation aborted at /usr/bin/psql line 19.



執行


$ perl -V



顯示


Can't locate strict.pm: /usr/share/perl/5.22/strict.pm: Permission denied at /usr/lib/x86_64-linux-gnu/perl/5.22/Config.pm line 9.
BEGIN failed--compilation aborted at /usr/lib/x86_64-linux-gnu/perl/5.22/Config.pm line 9.
Compilation failed in require.
BEGIN failed--compilation aborted.



執行下面指令,恢復「/usr/share/perl/5.22/strict.pm」原來的權限設定(注意:這個步驟很重要,要記得操作)。


$ sudo chmod +r /usr/share/perl/5.22/strict.pm



執行


$ ls -l /usr/share/perl/5.22/strict.pm



顯示


-rw-r--r-- 1 root root 1514 Mar 13 2016 /usr/share/perl/5.22/strict.pm



================================================================================

也可以使用「Can't locate strict.pm」當關鍵字來查詢網路上相關的討論。

另外一些套件的討論案例,紀錄在「[索引] 套件操作實務」。

================================================================================


以上提供參考

報告完畢


9/3 15:37:32
應用擴展 工具箱
回覆: ubuntun 14.04, psql 無法使用
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 33
HP : 161 / 806
MP : 508 / 13318
EXP: 24
離線
以下測試的環境是「Xubuntu 16.04 amd64 英文界面」。

================================================================================

## 前置作業

執行


$ apt-file search libc.mo



顯示


language-pack-ast-base: /usr/share/locale-langpack/ast/LC_MESSAGES/libc.mo
language-pack-be-base: /usr/share/locale-langpack/be/LC_MESSAGES/libc.mo
language-pack-bg-base: /usr/share/locale-langpack/bg/LC_MESSAGES/libc.mo
language-pack-bs: /usr/share/locale-langpack/bs/LC_MESSAGES/libc.mo
language-pack-bs-base: /usr/share/locale-langpack/bs/LC_MESSAGES/libc.mo
language-pack-ca-base: /usr/share/locale-langpack/ca/LC_MESSAGES/libc.mo
language-pack-cs-base: /usr/share/locale-langpack/cs/LC_MESSAGES/libc.mo
language-pack-da-base: /usr/share/locale-langpack/da/LC_MESSAGES/libc.mo
language-pack-de-base: /usr/share/locale-langpack/de/LC_MESSAGES/libc.mo
language-pack-el-base: /usr/share/locale-langpack/el/LC_MESSAGES/libc.mo
language-pack-en-base: /usr/share/locale-langpack/en_AU/LC_MESSAGES/libc.mo
language-pack-en-base: /usr/share/locale-langpack/en_GB/LC_MESSAGES/libc.mo
language-pack-eo-base: /usr/share/locale-langpack/eo/LC_MESSAGES/libc.mo
language-pack-es-base: /usr/share/locale-langpack/es/LC_MESSAGES/libc.mo
language-pack-fi-base: /usr/share/locale-langpack/fi/LC_MESSAGES/libc.mo
language-pack-fr-base: /usr/share/locale-langpack/fr/LC_MESSAGES/libc.mo
language-pack-gl-base: /usr/share/locale-langpack/gl/LC_MESSAGES/libc.mo
language-pack-hr-base: /usr/share/locale-langpack/hr/LC_MESSAGES/libc.mo
language-pack-hu-base: /usr/share/locale-langpack/hu/LC_MESSAGES/libc.mo
language-pack-ia-base: /usr/share/locale-langpack/ia/LC_MESSAGES/libc.mo
language-pack-id-base: /usr/share/locale-langpack/id/LC_MESSAGES/libc.mo
language-pack-it-base: /usr/share/locale-langpack/it/LC_MESSAGES/libc.mo
language-pack-ja-base: /usr/share/locale-langpack/ja/LC_MESSAGES/libc.mo
language-pack-km-base: /usr/share/locale-langpack/km/LC_MESSAGES/libc.mo
language-pack-ko-base: /usr/share/locale-langpack/ko/LC_MESSAGES/libc.mo
language-pack-lt-base: /usr/share/locale-langpack/lt/LC_MESSAGES/libc.mo
language-pack-ms-base: /usr/share/locale-langpack/ms/LC_MESSAGES/libc.mo
language-pack-nb-base: /usr/share/locale-langpack/nb/LC_MESSAGES/libc.mo
language-pack-nl-base: /usr/share/locale-langpack/nl/LC_MESSAGES/libc.mo
language-pack-oc-base: /usr/share/locale-langpack/oc/LC_MESSAGES/libc.mo
language-pack-pl-base: /usr/share/locale-langpack/pl/LC_MESSAGES/libc.mo
language-pack-pt-base: /usr/share/locale-langpack/pt/LC_MESSAGES/libc.mo
language-pack-pt-base: /usr/share/locale-langpack/pt_BR/LC_MESSAGES/libc.mo
language-pack-ro-base: /usr/share/locale-langpack/ro/LC_MESSAGES/libc.mo
language-pack-ru-base: /usr/share/locale-langpack/ru/LC_MESSAGES/libc.mo
language-pack-sk-base: /usr/share/locale-langpack/sk/LC_MESSAGES/libc.mo
language-pack-sl-base: /usr/share/locale-langpack/sl/LC_MESSAGES/libc.mo
language-pack-sq-base: /usr/share/locale-langpack/sq/LC_MESSAGES/libc.mo
language-pack-sv-base: /usr/share/locale-langpack/sv/LC_MESSAGES/libc.mo
language-pack-tr-base: /usr/share/locale-langpack/tr/LC_MESSAGES/libc.mo
language-pack-ug-base: /usr/share/locale-langpack/ug/LC_MESSAGES/libc.mo
language-pack-uk-base: /usr/share/locale-langpack/uk/LC_MESSAGES/libc.mo
language-pack-vi-base: /usr/share/locale-langpack/vi/LC_MESSAGES/libc.mo
language-pack-zh-hans-base: /usr/share/locale-langpack/zh_CN/LC_MESSAGES/libc.mo
language-pack-zh-hant-base: /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo



執行下面指令,安裝「language-pack-zh-hant-base」這個套件。


$ sudo apt-get install language-pack-zh-hant-base



執行


$ dpkg -S libc.mo | sort



顯示


language-pack-en-base: /usr/share/locale-langpack/en_AU/LC_MESSAGES/libc.mo
language-pack-en-base: /usr/share/locale-langpack/en_GB/LC_MESSAGES/libc.mo
language-pack-zh-hant-base: /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo



================================================================================

## 測試步驟

執行下面指令,產生一個空白的檔案「demo.txt」。


$ touch demo.txt



執行


$ ls demo.txt -l



顯示


-rw-rw-r-- 1 user user 0 Sep 3 17:55 demo.txt



執行


$ chmod -r demo.txt



執行


$ ls demo.txt -l



顯示


--w--w---- 1 user user 0 Sep 3 17:55 demo.txt



執行


$ cat demo.txt



顯示


cat: demo.txt: Permission denied



執行


$ locale



顯示


LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=



執行


LANGUAGE=zh_TW cat demo.txt



顯示


cat: demo.txt: 拒絕不符權限的操作




================================================================================

或是也可以搭配上面「#3」提到的測試步驟。

執行


sudo chmod -r /usr/share/perl/5.22/strict.pm
LANGUAGE=zh_TW psql
sudo chmod +r /usr/share/perl/5.22/strict.pm



顯示


Can't locate strict.pm: /usr/share/perl/5.22/strict.pm: 拒絕不符權限的操作 at /usr/bin/psql line 19.
BEGIN failed--compilation aborted at /usr/bin/psql line 19.




執行


sudo chmod -r /usr/share/perl/5.22/strict.pm
LANGUAGE=zh_TW ./test.pl
sudo chmod +r /usr/share/perl/5.22/strict.pm



顯示


Can't locate strict.pm: /usr/share/perl/5.22/strict.pm: 拒絕不符權限的操作 at ./test.pl line 3.
BEGIN failed--compilation aborted at ./test.pl line 3.



================================================================================

## 探索步驟

### 如何找出拒絕不符權限的操作(Permission denied)的「po檔」。

執行下面指令,下載「language-pack-zh-hant-base」的「Source Package


$ apt-get source language-pack-zh-hant-base



會下載兩個檔案

* language-pack-zh-hant-base_16.04+20160627.dsc
* language-pack-zh-hant-base_16.04+20160627.tar.gz

並且解開到資料夾「language-pack-zh-hant-base-16.04+20160627」。


然後執行下面指令,切換到資料夾「cd language-pack-zh-hant-base-16.04+20160627」


$ cd language-pack-zh-hant-base-16.04+20160627/



接下來執行


$ grep '拒絕不符權限的操作' ./* -R -n -B 4 -A 1



顯示


./data/zh_TW/LC_MESSAGES/libc.po-3224-
./data/zh_TW/LC_MESSAGES/libc.po-3225-#. TRANS Permission denied; the file permissions do not allow the attempted operation.
./data/zh_TW/LC_MESSAGES/libc.po-3226-#: nis/nis_error.h:11 nis/ypclnt.c:876 sysdeps/gnu/errlist.c:157
./data/zh_TW/LC_MESSAGES/libc.po-3227-msgid "Permission denied"
./data/zh_TW/LC_MESSAGES/libc.po:3228:msgstr "拒絕不符權限的操作"
./data/zh_TW/LC_MESSAGES/libc.po-3229-




================================================================================

### 如何找出拒絕不符權限的操作(Permission denied)的「mo檔」。

在已經有安裝「language-pack-zh-hant-base」這個套件的狀況下。

執行


$ grep '拒絕不符權限的操作' /usr/share/locale/* -R -n



顯示


Binary file /usr/share/locale/zh_HK/LC_MESSAGES/pidgin.mo matches
Binary file /usr/share/locale/zh_TW/LC_MESSAGES/pidgin.mo matches



執行


$ grep '拒絕不符權限的操作' /usr/share/locale-langpack/ -R -n



顯示


Binary file /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo matches



執行


$ dpkg -S /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo



顯示


language-pack-zh-hant-base: /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo



================================================================================

這個議題剛好可以對照最近討論的一篇「#2 回覆: liberoffice不能用fcitx打中文」對照著看。

還有對照更早之前的一篇「#4 回覆: 手機照片無法預覽」來看。

如何重新編譯「Source Package: language-pack-zh-hant-base」,
則是請參考另外一篇「#3 回覆: (新手求助)請問ubuntu終端機文字模式下 ls --help 顯示的幫助提示可以改中文嘛?

================================================================================

以上提供參考

報告完畢


9/3 18:45:51
應用擴展 工具箱
回覆: ubuntun 14.04, psql 無法使用
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 33
HP : 161 / 806
MP : 508 / 13318
EXP: 24
離線
以下測試環境是在「Xubuntu 16.04 amd64 英文界面」。

================================================================================


$ whereis locale



顯示


locale: /usr/bin/locale /usr/lib/locale /etc/locale.gen /etc/locale.alias /usr/include/locale.h /usr/share/locale /usr/share/man/man1/locale.1posix.gz /usr/share/man/man1/locale.1.gz /usr/share/man/man5/locale.5.gz /usr/share/man/man7/locale.7.gz



執行


$ dpkg -S /usr/bin/locale



顯示


libc-bin: /usr/bin/locale



執行


$ apt-cache showsrc libc-bin | grep '^Binary:' -B 1



顯示


Package: glibc
Binary: libc-bin, libc-dev-bin, libc-l10n, glibc-doc, glibc-source, locales, locales-all, nscd, multiarch-support, libc6, libc6-dev, libc6-dbg, libc6-pic, libc6-udeb, libc6.1, libc6.1-dev, libc6.1-dbg, libc6.1-pic, libc6.1-udeb, libc0.3, libc0.3-dev, libc0.3-dbg, libc0.3-pic, libc0.3-udeb, libc0.1, libc0.1-dev, libc0.1-dbg, libc0.1-pic, libc0.1-udeb, libc6-i386, libc6-dev-i386, libc6-sparc, libc6-dev-sparc, libc6-sparc64, libc6-dev-sparc64, libc6-s390, libc6-dev-s390, libc6-amd64, libc6-dev-amd64, libc6-powerpc, libc6-dev-powerpc, libc6-ppc64, libc6-dev-ppc64, libc6-mips32, libc6-dev-mips32, libc6-mipsn32, libc6-dev-mipsn32, libc6-mips64, libc6-dev-mips64, libc6-armhf, libc6-dev-armhf, libc6-armel, libc6-dev-armel, libc0.1-i386, libc0.1-dev-i386, libc6-x32, libc6-dev-x32, libc6-i686, libc6-xen, libc0.1-i686, libc6.1-alphaev67



================================================================================

執行


$ dpkg -S /usr/include/locale.h



顯示


libc6-dev:amd64: /usr/include/locale.h



執行


$ apt-cache showsrc libc6-dev | grep '^Binary:' -B 1



顯示


Package: glibc
Binary: libc-bin, libc-dev-bin, libc-l10n, glibc-doc, glibc-source, locales, locales-all, nscd, multiarch-support, libc6, libc6-dev, libc6-dbg, libc6-pic, libc6-udeb, libc6.1, libc6.1-dev, libc6.1-dbg, libc6.1-pic, libc6.1-udeb, libc0.3, libc0.3-dev, libc0.3-dbg, libc0.3-pic, libc0.3-udeb, libc0.1, libc0.1-dev, libc0.1-dbg, libc0.1-pic, libc0.1-udeb, libc6-i386, libc6-dev-i386, libc6-sparc, libc6-dev-sparc, libc6-sparc64, libc6-dev-sparc64, libc6-s390, libc6-dev-s390, libc6-amd64, libc6-dev-amd64, libc6-powerpc, libc6-dev-powerpc, libc6-ppc64, libc6-dev-ppc64, libc6-mips32, libc6-dev-mips32, libc6-mipsn32, libc6-dev-mipsn32, libc6-mips64, libc6-dev-mips64, libc6-armhf, libc6-dev-armhf, libc6-armel, libc6-dev-armel, libc0.1-i386, libc0.1-dev-i386, libc6-x32, libc6-dev-x32, libc6-i686, libc6-xen, libc0.1-i686, libc6.1-alphaev67




================================================================================

執行


$ dpkg -l '*libc*'



會顯示很多筆,就不列出來了。

執行


$ dpkg -l '*libc6*'



顯示


Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================-===================-===================-======
ii libc6:amd64 2.23-0ubuntu9 amd64 GNU C Library: Shared libraries
un libc6-amd64 <none> <none> (no description available)
ii libc6-dbg:amd64 2.23-0ubuntu9 amd64 GNU C Library: detached debugging symbols
ii libc6-dev:amd64 2.23-0ubuntu9 amd64 GNU C Library: Development Libraries and Header Files
ii libc6-dev-i386 2.23-0ubuntu9 amd64 GNU C Library: 32-bit development libraries for AMD64
ii libc6-dev-x32 2.23-0ubuntu9 amd64 GNU C Library: X32 ABI Development Libraries for AMD64
ii libc6-i386 2.23-0ubuntu9 amd64 GNU C Library: 32-bit shared libraries for AMD64
ii libc6-x32 2.23-0ubuntu9 amd64 GNU C Library: X32 ABI Shared libraries for AMD64
un libc6.1 <none> <none> (no description available)
un libc6.1-dev <none> <none> (no description available)



執行


$ apt-cache showsrc libc6 | grep '^Binary:' -B 1



顯示


Package: glibc
Binary: libc-bin, libc-dev-bin, libc-l10n, glibc-doc, glibc-source, locales, locales-all, nscd, multiarch-support, libc6, libc6-dev, libc6-dbg, libc6-pic, libc6-udeb, libc6.1, libc6.1-dev, libc6.1-dbg, libc6.1-pic, libc6.1-udeb, libc0.3, libc0.3-dev, libc0.3-dbg, libc0.3-pic, libc0.3-udeb, libc0.1, libc0.1-dev, libc0.1-dbg, libc0.1-pic, libc0.1-udeb, libc6-i386, libc6-dev-i386, libc6-sparc, libc6-dev-sparc, libc6-sparc64, libc6-dev-sparc64, libc6-s390, libc6-dev-s390, libc6-amd64, libc6-dev-amd64, libc6-powerpc, libc6-dev-powerpc, libc6-ppc64, libc6-dev-ppc64, libc6-mips32, libc6-dev-mips32, libc6-mipsn32, libc6-dev-mipsn32, libc6-mips64, libc6-dev-mips64, libc6-armhf, libc6-dev-armhf, libc6-armel, libc6-dev-armel, libc0.1-i386, libc0.1-dev-i386, libc6-x32, libc6-dev-x32, libc6-i686, libc6-xen, libc0.1-i686, libc6.1-alphaev67



================================================================================

執行


$ apt-get source libc-bin



或是執行


$ apt-get source libc6



或是執行


$ apt-get source libc6-dev



或是執行


$ apt-get source glibc



就會下載三個檔案

glibc_2.23-0ubuntu9.debian.tar.xz
glibc_2.23-0ubuntu9.dsc
glibc_2.23.orig.tar.xz

並且解開到資料夾「glibc-2.23」

執行


$ grep 'Permission denied' glibc-2.23/* -R -n



顯示


glibc-2.23/debian/patches/git-updates.diff:34433: #. TRANS Permission denied; the file permissions do not allow the attempted operation.
glibc-2.23/debian/patches/git-updates.diff:34436: msgid "Permission denied"
glibc-2.23/debian/patches/git-updates.diff:54310: #. TRANS Permission denied; the file permissions do not allow the attempted operation.
glibc-2.23/debian/patches/kfreebsd/local-sysdeps.diff:826:+#define EACCES 13 /* Permission denied */
glibc-2.23/elf/dl-minimal.c:182: msg = (char *) "Permission denied";
glibc-2.23/nis/nis_error.h:11:S(N_("Permission denied"))
glibc-2.23/nis/ypclnt.c:862: str = N_("Permission denied");
...略...
glibc-2.23/po/zh_TW.po:3196:#. TRANS Permission denied; the file permissions do not allow the attempted operation.
glibc-2.23/po/zh_TW.po:3198:msgid "Permission denied"
...略...
glibc-2.23/posix/execvpe.c:177: /* Record the we got a `Permission denied' error. If we end
glibc-2.23/stdio-common/errlist.c:31: "Permission denied", /* 8 = EACCES */
glibc-2.23/sunrpc/rpcsvc/nfs_prot.x:63: NFSERR_ACCES=13, /* Permission denied */
glibc-2.23/sysdeps/gnu/errlist.c:157:TRANS Permission denied; the file permissions do not allow the attempted operation. */
glibc-2.23/sysdeps/gnu/errlist.c:158: [ERR_REMAP (EACCES)] = N_("Permission denied"),
glibc-2.23/sysdeps/unix/bsd/bsd4.4/kfreebsd/bits/errno.h:57:#define EACCES 13 /* Permission denied */
glibc-2.23/sysdeps/mach/hurd/bits/errno.h:47:#define EACCES _HURD_ERRNO (13)/* Permission denied */



對照上面「#4」有一行。


./data/zh_TW/LC_MESSAGES/libc.po-3226-#: nis/nis_error.h:11 nis/ypclnt.c:876 sysdeps/gnu/errlist.c:157



================================================================================

執行


$ grep '拒絕不符權限的操作' glibc-2.23/* -R -n -A 1 -B 4



顯示


glibc-2.23/po/zh_TW.po-3195-
glibc-2.23/po/zh_TW.po-3196-#. TRANS Permission denied; the file permissions do not allow the attempted operation.
glibc-2.23/po/zh_TW.po-3197-#: nis/nis_error.h:11 nis/ypclnt.c:876 sysdeps/gnu/errlist.c:158
glibc-2.23/po/zh_TW.po-3198-msgid "Permission denied"
glibc-2.23/po/zh_TW.po:3199:msgstr "拒絕不符權限的操作"
glibc-2.23/po/zh_TW.po-3200-



================================================================================

執行


$ grep '/usr/share/locale-langpack' glibc-2.23/* -R -n



顯示


glibc-2.23/debian/patches/ubuntu/local-altlocaledir.diff:3:# DP: /usr/share/locale-langpack
glibc-2.23/debian/patches/ubuntu/local-altlocaledir.diff:25:+ const char* langpack_dir = "/usr/share/locale-langpack";
glibc-2.23/intl/l10nflist.c:289: const char* langpack_dir = "/usr/share/locale-langpack";




================================================================================

執行


$ grep '__strerror_r' glibc-2.23/* -n -R | grep strerror.c



顯示


glibc-2.23/ChangeLog:70109: * string/_strerror.c (__strerror_r): Print negative errors as signed
glibc-2.23/ChangeLog.11:3688: * sysdeps/generic/_strerror.c (__strerror_r): Don't zero-fill the
glibc-2.23/ChangeLog.11:3690: * sysdeps/mach/_strerror.c (__strerror_r): Likewise.
glibc-2.23/ChangeLog.13:1960: * sysdeps/mach/_strerror.c (__strerror_r): Add libc_hidden_def.
glibc-2.23/ChangeLog.13:4537: * sysdeps/generic/_strerror.c (__strerror_r): Likewise.
glibc-2.23/ChangeLog.17:14672: * string/_strerror.c (__strerror_r): Add __builtin_expect.
glibc-2.23/ChangeLog.8:3491: * sysdeps/generic/_strerror.c (__strerror_r): Don't return NULL
glibc-2.23/ChangeLog.8:5531: * string/strerror.c: Call __strerror_r for doing the real work.
glibc-2.23/ChangeLog.8:5532: * sysdeps/generic/_strerror.c: Rename function to __strerror_r and
glibc-2.23/string/_strerror.c:37:__strerror_r (int errnum, char *buf, size_t buflen)
glibc-2.23/string/_strerror.c:73:weak_alias (__strerror_r, strerror_r)
glibc-2.23/string/_strerror.c:74:libc_hidden_def (__strerror_r)
glibc-2.23/string/xpg-strerror.c:29: const char *estr = __strerror_r (errnum, buf, buflen);
glibc-2.23/string/xpg-strerror.c:31: /* We know that __strerror_r returns buf (with a dynamically computed
glibc-2.23/string/strerror.c:31: char *ret = __strerror_r (errnum, NULL, 0);
glibc-2.23/string/strerror.c:42: return __strerror_r (errnum, buf, 1024);
glibc-2.23/sysdeps/mach/_strerror.c:37:__strerror_r (int errnum, char *buf, size_t buflen)
glibc-2.23/sysdeps/mach/_strerror.c:119:libc_hidden_def (__strerror_r)
glibc-2.23/sysdeps/mach/_strerror.c:120:weak_alias (__strerror_r, strerror_r)



================================================================================

執行


$ grep '_sys_errlist_internal' glibc-2.23/* -R -n



顯示


glibc-2.23/ChangeLog.13:1409: (__strerror_r): Use _sys_errlist_internal instead of _sys_errlist,
glibc-2.23/ChangeLog.13:2466: * sysdeps/gnu/errlist.awk: Make output define _sys_errlist_internal
glibc-2.23/ChangeLog.13:2474: (_sys_errlist_internal): Define this as a macro for _hurd_errlist.
glibc-2.23/ChangeLog.13:8593: * sysdeps/gnu/errlist.awk: Define _sys_errlist_internal and
glibc-2.23/ChangeLog.13:8596: * include/stdio.h (_sys_errlist_internal): Declare as hidden.
glibc-2.23/include/stdio.h:117:extern const char *const _sys_errlist_internal[] attribute_hidden;
glibc-2.23/string/_strerror.c:40: || _sys_errlist_internal[errnum] == NULL, 0))
glibc-2.23/string/_strerror.c:71: return (char *) _(_sys_errlist_internal[errnum]);
glibc-2.23/string/strerror_l.c:46: || _sys_errlist_internal[errnum] == NULL, 0))
glibc-2.23/string/strerror_l.c:56: return (char *) translate (_sys_errlist_internal[errnum], loc);
glibc-2.23/string/xpg-strerror.c:37: || _sys_errlist_internal[errnum] == NULL);
glibc-2.23/string/xpg-strerror.c:43: && _sys_errlist_internal[errnum] != NULL);
glibc-2.23/sysdeps/mach/hurd/errlist.c:21:#define _sys_errlist_internal _hurd_errlist
glibc-2.23/sysdeps/gnu/errlist.c:19:const char *const _sys_errlist_internal[ERRLIST_SIZE] =
glibc-2.23/sysdeps/gnu/errlist.c:1480: (sizeof _sys_errlist_internal / sizeof _sys_errlist_internal [0])
glibc-2.23/sysdeps/gnu/errlist-compat.awk:97: printf "declare_symbol_alias (__sys_errlist_%s, _sys_errlist_internal,", \
glibc-2.23/sysdeps/gnu/errlist-compat.awk:106: printf "declare_symbol_alias (___sys_errlist_%s, _sys_errlist_internal,", \
glibc-2.23/sysdeps/gnu/errlist-compat.awk:117:extern const char *const __sys_errlist_internal[NERR];\n\
glibc-2.23/sysdeps/gnu/errlist-compat.awk:119:strong_alias (_sys_errlist_internal, __sys_errlist_internal)\n\
glibc-2.23/sysdeps/gnu/errlist-compat.awk:122:versioned_symbol (libc, _sys_errlist_internal, sys_errlist, %s);\n\
glibc-2.23/sysdeps/gnu/errlist-compat.awk:123:versioned_symbol (libc, __sys_errlist_internal, _sys_errlist, %s);\n\
glibc-2.23/sysdeps/gnu/errlist.awk:59: print "const char *const _sys_errlist_internal[ERRLIST_SIZE] =";
glibc-2.23/sysdeps/gnu/errlist.awk:110: print " (sizeof _sys_errlist_internal / sizeof _sys_errlist_internal [0])";



================================================================================

以上提供參考

報告完畢


9/4 16:07:38
應用擴展 工具箱
回覆: ubuntun 14.04, psql 無法使用
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 33
HP : 161 / 806
MP : 508 / 13318
EXP: 24
離線
以下測試環境是在「Xubuntu 16.04 amd64 英文界面」。

================================================================================

## main.c


#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <unistd.h>

FILE * open_sesame (char *name)
{
	FILE *stream;

	setlocale(LC_ALL, "");

	errno = 0;
	stream = fopen(name, "r");

	if (stream == NULL) {
		fprintf(
			stderr,
			"%s: Couldn't open file %s; %s (%d)\n",
			program_invocation_short_name,
			name,
			strerror(errno),
			errno
		);
		sleep(180);
		exit(EXIT_FAILURE);
	}

	return stream;

}

int main (int argc, char *argv[])
{
	open_sesame("./demo.txt");

	exit(EXIT_SUCCESS);
}

/*
int main (int argc, char *argv[])
{

	if (argc < 2) {
		printf(
			"Usage:\n$ %s file\n",
			program_invocation_short_name
		);
		exit(EXIT_FAILURE);
	}

	open_sesame(argv[1]);

	exit(EXIT_SUCCESS);
}
*/

/*
https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html
https://packages.ubuntu.com/source/xenial/hello
http://www.cplusplus.com/reference/cstring/strerror/
*/



* $ man 3 errno
* $ man 3 strerror
* $ man 3 sleep
* $ man 3 fopen
* $ man 3 exit

================================================================================

## 編譯

執行下面指令編譯


$ gcc -o demo-app main.c



會產生一個執行檔「demo-app」。

================================================================================

## locale

測試環境「/etc/default/locale」這個檔案的內容如下,


# File generated by update-locale
LANG="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"



執行


$ locale



顯示


LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=



事先有安裝「language-pack-zh-hant-base」這個套件,可以參考「#4」的說明。


$ sudo apt-get install language-pack-zh-hant-base



================================================================================

## 測試一

測試前,並沒有先準備「demo.txt」這個檔案,下面「測試二」以後,才會測試有「demo.txt」這個檔案的狀況。

執行


$ ./demo-app



顯示


demo-app: Couldn't open file ./demo.txt; No such file or directory (2)



執行


$ LANGUAGE=zh_TW ./demo-app



顯示


demo-app: Couldn't open file ./demo.txt; 沒有此一檔案或目錄 (2)



想到之前有一篇相關的討論案例「#3 回覆: sudo dpkg -i 出現了以下錯誤訊息」。

================================================================================

## 測試檔案

執行下面指令,產生一個空白的檔案「demo.txt」。


$ touch demo.txt



執行


$ ls demo.txt -l



顯示


-rw-rw-r-- 1 user user 0 Sep 4 15:17 demo.txt



執行


$ chmod -r demo.txt



執行


$ ls demo.txt -l



顯示


--w--w---- 1 user user 0 Sep 4 15:17 demo.txt



================================================================================

## 測試二

執行


$ ./demo-app



顯示


demo-app: Couldn't open file ./demo.txt; Permission denied (13)



執行


$ ps aux | grep demo-app



顯示


user 11143 0.0 0.0 10172 644 pts/9 S+ 15:22 0:00 ./demo-app
user 11426 0.0 0.0 17128 936 pts/11 S+ 15:23 0:00 grep --color=auto demo-app



執行


$ lsof -p 11143



顯示


...略...
demo-app 11143 user mem REG 8,18 5950752 4197118 /usr/lib/locale/locale-archive
demo-app 11143 user mem REG 8,18 1868984 10301466 /lib/x86_64-linux-gnu/libc-2.23.so
demo-app 11143 user mem REG 8,18 162632 10301444 /lib/x86_64-linux-gnu/ld-2.23.so
...略...



================================================================================

## 測試三

執行


$ LANGUAGE=zh_TW ./demo-app



顯示


demo-app: Couldn't open file ./demo.txt; 拒絕不符權限的操作 (13)



執行


$ ps aux | grep demo-app



顯示


user 11499 0.0 0.0 10332 640 pts/9 S+ 15:27 0:00 ./demo-app
user 11511 0.0 0.0 17128 1096 pts/11 S+ 15:27 0:00 grep --color=auto demo-app



執行


$ lsof -p 11499



顯示


...略...
demo-app 11499 user mem REG 8,18 5950752 4197118 /usr/lib/locale/locale-archive
demo-app 11499 user mem REG 8,18 1868984 10301466 /lib/x86_64-linux-gnu/libc-2.23.so
demo-app 11499 user mem REG 8,18 162632 10301444 /lib/x86_64-linux-gnu/ld-2.23.so
demo-app 11499 user mem REG 8,18 26258 4352759 /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
demo-app 11499 user mem REG 8,18 131878 4649366 /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo
...略...



關於「lsof」的用法,請參考「鳥哥的 Linux 私房菜 / 第十六章、程序管理與 SELinux 初探 / 16.4.3 查詢已開啟檔案或已執行程序開啟之檔案: fuser, lsof, pidof」。

執行


$ dpkg -S /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo



顯示


language-pack-zh-hant-base: /usr/share/locale-langpack/zh_TW/LC_MESSAGES/libc.mo



================================================================================

## errno

* /usr/include/errno.h
* /usr/include/bits/errno.h
* /usr/include/linux/errno.h
* /usr/include/asm/errno.h
* /usr/include/asm-generic/errno.h
* /usr/include/asm-generic/errno-base.h

$ man 3 errno

可以看到其中有一行如下


EACCES Permission denied (POSIX.1)



執行


$ grep 'EACCES' /usr/include/asm-generic/errno-base.h -n



顯示


16:#define      EACCES          13      /* Permission denied */




$ man 3 errno

可以看到其中有一行如下


ENOENT No such file or directory (POSIX.1)



執行


$ grep 'ENOENT' /usr/include/asm-generic/errno-base.h -n



顯示


5:#define       ENOENT           2      /* No such file or directory */



執行


$ dpkg -S /usr/include/asm-generic/errno-base.h



顯示


linux-libc-dev:amd64: /usr/include/asm-generic/errno-base.h



================================================================================

## 測試四

執行


$ cat demo.txt



顯示


cat: demo.txt: Permission denied



執行


$ LANGUAGE=zh_TW cat demo.txt



顯示


cat: demo.txt: 拒絕不符權限的操作



================================================================================

## 測試五

執行


$ more demo.txt



顯示


more: cannot open demo.txt: Permission denied



執行


$ LANGUAGE=zh_TW more demo.txt



顯示


more: 無法開啟 demo.txt: 拒絕不符權限的操作



================================================================================

## 測試六

執行


$ less demo.txt



顯示


demo.txt: Permission denied



執行


$ LANGUAGE=zh_TW less demo.txt



顯示


demo.txt: 拒絕不符權限的操作



================================================================================

## 測試七

執行


$ bash demo.txt



顯示


bash: demo.txt: Permission denied



執行


$ LANGUAGE=zh_TW bash demo.txt



顯示


bash: demo.txt: 拒絕不符權限的操作



================================================================================

## 測試八

執行


$ perl demo.txt



顯示


Can't open perl script "demo.txt": Permission denied



執行


$ LANGUAGE=zh_TW perl demo.txt



顯示


Can't open perl script "demo.txt": 拒絕不符權限的操作



================================================================================

## 測試九

執行下面指令,產生一個檔案「demo.sh」。


$ touch demo.sh



執行


$ ls demo.sh -l



顯示


-rw-rw-r-- 1 user user 0 Sep 4 17:09 demo.sh



執行


$ ./demo.sh



顯示


bash: ./demo.sh: Permission denied



執行


$ LANGUAGE=zh_TW ./demo.sh



顯示


bash: ./demo.sh: 拒絕不符權限的操作



這個測試,以前有一個討論案例「#3 回覆: *拒絕不符權限的操作* -- 錯誤訊息.尋求協助!」。

================================================================================

## 測試十

執行


$ gettext "Permission denied"



顯示


Permission denied



執行


$ LANGUAGE=zh_TW gettext -d libc "Permission denied"



顯示


拒絕不符權限的操作



執行


$ LANGUAGE=zh_TW TEXTDOMAIN=libc gettext "Permission denied"




顯示


拒絕不符權限的操作




$ man 1 gettext

================================================================================

## 測試十ㄧ

### test-011.c


#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <libintl.h>

#define PACKAGE "libc"
#define LOCALEDIR "/usr/share/locale"
#define _(msgid) gettext (msgid)

int main (int argc, char *argv[])
{
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	printf("LANGUAGE=%s\n", getenv("LANGUAGE"));

	printf(_("Permission denied"));

	printf("\n");

	exit(EXIT_SUCCESS);
}



執行下面指令,編譯「test-011.c」


$ gcc -o test-011 test-011.c



執行


./test-011



顯示


LANGUAGE=en_US
Permission denied




執行


$ LANGUAGE=zh_TW ./test-011



顯示


LANGUAGE=zh_TW
拒絕不符權限的操作




這個測試,可以對照另一篇回覆「#3 回覆: (新手求助)請問ubuntu終端機文字模式下 ls --help 顯示的幫助提示可以改中文嘛?」。


================================================================================


* $ man 1 locale
* $ man 5 locale
* $ man 7 locale
* $ man 5 locale.conf
* $ man 1 localectl
* $ man 8 systemd-localed
* $ man 8 systemd-localed.service

執行「man 7 locale」,

可以看到下面一段說明


LC_MESSAGES
	   This  category  affects  the  language  in  which  messages  are
	   displayed and what an affirmative or negative answer looks like.
	   The GNU C library  contains  the  gettext(3),  ngettext(3),  and
	   rpmatch(3)  functions  to ease the use of this information.  The
	   GNU gettext  family  of  functions  also  obey  the  environment
	   variable LANGUAGE (containing a colon-separated list of locales)
	   if the category is set to a valid locale other than  "C".   This
	   category also affects the behavior of catopen(3).



也可以參考「鳥哥的 Linux 私房菜 / 第十章、認識與學習BASH / 10.2.4 影響顯示結果的語系變數 (locale)」的說明。

一些「locale」的討論案例,紀錄在「[索引] 文件編碼」。

* $ man bash
* $ man 7 environ
* $ man 3 getenv
* $ man 1posix env
* $ man printenv

也可以參考「Ubuntu Community Help Wiki / EnvironmentVariables」,
或是參考「Debian Wiki / EnvironmentVariables」和「Debian Wiki / Locale」。


* $ man 3 gettext


## GNU gettext utilities

* 2.3.2 Locale Environment Variables
* 2.3.3 Specifying a Priority List of Languages


## The GNU C Library

* 25.4 Environment Variables

## Wikipidia

* gettext / 2.3 Running

## 如何探索「Ubuntu」

* 關於「/etc/environment」
* 關於「/etc/default/locale」
* 關於「/proc/[pid]/environ」

================================================================================

先執行


$ locale



顯示


LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=



然後執行


$ LANGUAGE=zh_TW locale



顯示


LANG=en_US.UTF-8
LANGUAGE=zh_TW
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=



再執行


$ locale



顯示


LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=



================================================================================

執行


$ LANGUAGE=zh_TW LC_CTYPE=zh_TW.UTF-8 LC_MESSAGES=zh_TW.UTF-8 locale



顯示


LANG=en_US.UTF-8
LANGUAGE=zh_TW
LC_CTYPE=zh_TW.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=zh_TW.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=



再執行


$ locale



顯示


LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=



================================================================================

以上提供參考

報告完畢


9/4 16:17:17
應用擴展 工具箱
回覆: ubuntun 14.04, psql 無法使用
會員二級
註冊日期:
2008/5/5 8:18
所屬群組:
已註冊使用者
等級: 4
HP : 0 / 94
MP : 12 / 2648
EXP: 76
離線
感謝,
時間上, 我直接就重裝了,下次遇到再仿照你的流程跑一次

9/27 10:24:29
應用擴展 工具箱


 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.