在 Solaris 8 中将 ps 输出扩展到 80 个以上字符

发布于 2024-10-31 06:15:00 字数 68 浏览 1 评论 0原文

如何在 Solaris 中扩展 ps -fe 的输出,使其显示超过 80 个字符?我的进程有几个参数,进程名称无法再显示。

How do you extend the output of ps -fe in Solaris so that it displays more than 80 characters? My process has several arguments and the process name could not be displayed anymore.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

dawn曙光 2024-11-07 06:15:00

您无法使用默认的 ps (/usr/bin/ps) 显示它们,该 ps 是 SVR4 的常规 ps。

要获得完整的参数行,请使用 BSD ps(UCB = 加州大学伯克利分校):

/usr/ucb/ps -alxwww

You can't display them with the default ps (/usr/bin/ps) which is a SVR4 regular one.

To get the full argument line, use the BSD ps (UCB = University of California at Berkeley):

/usr/ucb/ps -alxwww
一江春梦 2024-11-07 06:15:00

我们终于在 Solaris 中修复了这个问题;从 Solaris 11.3 SRU 5 开始,所有原始参数向量以及环境变量都可以从 /proc 检索。 ps 现在将打印所有命令行。

已在 Solaris 11.3 SRU 5 中修复

We have finally fixed this in Solaris; as of Solaris 11.3 SRU 5, all original argument vectors as well as the environment variables can be retrieved from /proc. ps will now print all of the command line.

Fixed in Solaris 11.3 SRU 5

柏林苍穹下 2024-11-07 06:15:00

简单的答案是,对于 Solaris 上其他用户拥有的进程,无法可靠地获取进程的完整参数。如果您拥有 root 或其他特权访问权限,则可以在旧版本上使用 /usr/ucb/ps,在较新版本上使用“pargs”或类似工具(没有适用于所有版本的工具)。

本质上,Solaris 在进程启动时存储原始 args,而大多数其他平台允许 ps 通过某种方式在进程运行时访问 argv 的内容。该存储副本位于特殊的内核数据结构中,大小有限(80 字节)。这也意味着程序不可能以有用或邪恶的方式修改 ps 显示的启动后参数。

因此,如果您需要出于可移植目的访问命令行(例如 pid 检查),您将需要选择通过 hack 强制执行短命令行(例如启动程序控制的 execp 路径而无需绝对路径),否则您将需要放弃可移植性Solaris 上的功能。

The simple answer is that there is no way to reliably acquire the full arguments to processes on Solaris for processes owned by other users. If you have root or other privileged access you can use /usr/ucb/ps on older versions, and 'pargs' or similar tools on newer versions (there is no tool which works across all versions).

Essentially Solaris stores the original args at process start time, while most other platforms allow ps to access, via some means, the contents of argv at runtime for the process. This stored-copy is in a special kernel data structure with limited (80 byte) size. This also means that it's not possible for a program to modify the args post-start as displayed by ps for useful or nefarious means.

Thus, if you need to access the command line for portable purposes, such as pid checking, you will need to choose between enforcing a short command line via hacks like launching programs controlled execp paths without absolute paths, or you will need to forgo that portable functionality on Solaris.

套路撩心 2024-11-07 06:15:00

你可以使用 pargs PID
它会给你比 ps 更多的信息

you can use pargs PID
it will give you more information than ps

蹲墙角沉默 2024-11-07 06:15:00

尝试ps -efl。如果这不起作用(我手边没有 Solaris 盒子),您也可以尝试 ps -efl | cat (因为某些程序检查它们是否输出到终端来决定它们的输出宽度)。

Try ps -efl. If that doesn't work (I don't have a Solaris box handy) you can also try ps -efl | cat (as some programs check whether they're outputting to a terminal to decide on their output width).

横笛休吹塞上声 2024-11-07 06:15:00

ps 有两组可用选项。其他人会用正确的名称((可能是 BSD 和 SRVn)?)

使用非选项前面带有连字符的版本,您可以执行

ps auxww(w?) | grep ${PID} 来扩展打印的命令详细信息的长度(再次注意,没有前导“-”选项指示符)。

请注意,在某些情况下,您会在实际命令之前看到很多环境变量分配,即 myPath=... cfgFile=... /path/to/command ... args ...

我认为“www”在有些系统会打印所有内容,无论命令有多长。

最后,根据我使用 ps 做很多疯狂事情的​​经验,我偶尔会得到一个 PID 并且输出会显示前 6 个?列,但为命令保留的空间为空或具有某种占位符值。我最终通过搜索 comp.unix.shell 找到了原因,但现在无法确定,而且我现在无法访问 Solaris 系统。

我希望这有帮助。

There are two sets of options available for ps. Others will chime in with the correct names ( ( maybe BSD and SRVn)?)

With the non-options-preceded-with-a-hyphen-version, you can do

ps auxww(w?) | grep ${PID} to extend the length of the command detail that is printed (again, notice NO leading '-' option indicator).

Note that in some cases you will see a lot of environment variable assignments before the actually command, i.e. myPath=... cfgFile=... /path/to/command ... args ...

I think that 'www' in some systems will print everything, regardless how long the command is.

Finally, in my experience using ps to do a lot of crazy things, I would ocassionally have a PID and the output would display the first 6? columns, but the space reserved for the command was empty or had some sort of place holder value. I eventually found out why that was true, by searching comp.unix.shell, but it's too long ago now to be sure and I don't have access to Solaris systems right now.

I hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文