14.21 已知errno如何获取错误描述
https://scz.617.cn/unix/202211151428.txt
Q:
Windows中可以这样查看指定错误码的描述信息
$ net helpmsg 5 Access is denied.
Linux中如何达到同样目的?
A: scz 2022-11-15
aptitude install moreutils
该包带有/usr/bin/errno,参看errno(1)、errno(3)。
显示所有errno的数值及描述
$ errno -l EPERM 1 Operation not permitted ENOENT 2 No such file or directory ESRCH 3 No such process ...
显示5号错误描述
$ errno 5 EIO 5 Input/output error
显示所有描述信息包含"access"的错误码,大小写不敏感
$ errno -s access ELIBACC 79 Can not access a needed shared library ELIBBAD 80 Accessing a corrupted shared library
errno可用于SHELL编程,若只是交互式查询,检查这两个文件即可
/usr/include/asm-generic/errno-base.h /usr/include/asm-generic/errno.h
$ grep -hw 1 /usr/include/asm-generic/errno*
define EPERM 1 / Operation not permitted /
$ grep -hw 5 /usr/include/asm-generic/errno*
define EIO 5 / I/O error /
A: scz 2022-11-15
pip3 install pwn
该模块会安装/usr/local/bin/errno,这其实是个Python脚本
$ errno 2
define ENOENT 2
No such file or directory
$ errno 5
define EIO 5
Input/output error