开发者

Piping the output of a custom ssh console

Our product exposes an admin console by embedding an ssh server (java based) and exposing a bunch of custom commands. The output of some of these commands can be pretty verbose. Currently we handl开发者_StackOverflow中文版e these by having flags like -dump to dump output to a text file for later processing.

I was wondering if it were possible to pipe the output to standard unix utilities like grep (non interactive) and less (interactive) so that the user could analyze the results without leaving the terminal. This needs to work only on linux currently.

Piping to interactive commands seems almost impossible, but any remotely helpful suggestions would be greatly appreciated (and upvoted)


Keep the interactive commands on the local host and non-interactive on the remote, i.e.

ssh remotehost ls /bin

ssh remotehost cat /var/log/messages | less

The less command runs locally unless you include it in quotes:

ssh remotehost "cat /var/log/messages | less"


I would have made a wrapper-script sth like this:

#!/bin/bash
# filename: custom-command
/usr/bin/java /path/to/custom-command.java $@ | less
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜