已知errno如何获取错误描述
2022-11-15 23:59:41 Author: mp.weixin.qq.com(查看原文) 阅读量:8 收藏

14.21 已知errno如何获取错误描述

http://scz.617.cn:8/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的数值及描述

$ /usr/bin/errno -l
EPERM 1 Operation not permitted
ENOENT 2 No such file or directory
ESRCH 3 No such process
...

显示5号错误描述

$ /usr/bin/errno 5
EIO 5 Input/output error

显示所有描述信息包含"access"的错误码,大小写不敏感

$ /usr/bin/errno -s access
ELIBACC 79 Can not access a needed shared library
ELIBBAD 80 Accessing a corrupted shared library

/usr/bin/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


文章来源: https://mp.weixin.qq.com/s?__biz=MzUzMjQyMDE3Ng==&mid=2247486308&idx=1&sn=947958f1a32b4c234aff99a9b2875059&chksm=fab2c85bcdc5414d17d4f20f1a747cafb8c31851b0cd3b682171d350156816b3bea6fd0e6b67#rd
如有侵权请联系:admin#unsafe.sh