如何在linux上分享你shell命令的输出
linux shell 分享
前段时间我发布了一篇关于[shelr.tv](http://linuxaria.com/recensioni/shelr-broadcast-your-linux-shell-on-the-net)这个网站的文章，它提供一个服务允许你从网站上直接分享你的[终端](http://linuxaria.com/tag/shell)记录。


![](/data/attachment/album/201409/15/171833cv7xzu1xemcexuo1.jpg)


现在shelr.tv这个网站似乎关闭了，然后我四处寻找是否有类似的网站，于是我发现了[commands.com](https://commands.com/)。


从它的主页上来看，它的服务和其他网站提供的服务是类似的，因此让我们来测试它。


### 步骤 1 – 在网站上注册


只需要[注册](https://commands.com/Register/Index)一个新的 用户名/密码，或者直接使用你的github账户快速登录。


### 步骤 2 – 下载安装monitor程序


[Monitor](https://github.com/dtannen/monitor)是一个命令行工具，它能捕获命令行的输入输出并且发送到commands.com网站上，这个程序是开源的，并托管在github上。


Monitor使得仓库的设置/安装变得更简单。通过它，你能方便地向人们展示最常见的错误与命令的输出。


简而言之，你能方便地和世界分享你的命令及其输出。


通过如下简单几步来安装它：


1) 克隆github上的这个项目的仓库，这样你能获得最新的源代码。


要完成这步，你需要在系统中已经安装了git命令，如果你得到关于这个命令的报错信息，你可以使用包管理工具来安装它，例如：


基于Debian的发布版：



```
apt-get install git

```

Redhat/Centos/Fedora发布版：



```
yum install git

```

现在从终端克隆这个仓库：



```
git clone https://github.com/dtannen/monitor.git

```

2) 安装readline和curl，这些库是通过源码构建程序的先决条件：


基于Debian的发布版：



```
apt-get install libreadline-dev libcurl4-openssl-dev

```

Redhat/Centos/Fedora发布版：



```
yum install readline-devel curl-devel

```

3) 构建程序：


要完成这步，你必须进入刚刚用git克隆的目录，然后编译这个c程序：



```
cd monitor
make
sudo make install

```

默认安装将把二进制文件放入/usr/local/bin目录下。


[![](/7297f23ba2e0a5d31d4f3acc9fb4059d4d42f340/687474703a2f2f63646e2e6c696e7578617269612e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031342f30382f636f6d6d616e64732e706e67)](https://camo.githubusercontent.com/7297f23ba2e0a5d31d4f3acc9fb4059d4d42f340/687474703a2f2f63646e2e6c696e7578617269612e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031342f30382f636f6d6d616e64732e706e67)


### 步骤 3 – 使用monitor命令


monitor命令特别简单易用：



```
monitor {-d} {-h} {-u <username>}

    -d : 不删除/tmp下的文件
    -h : 帮助
    -u : commands.com用户名</username>

```

要退出monitor程序，需要按ctrl-c。


对我来说这仅仅意味着打开一个终端然后执行这些命令：



```
riccio@mint-desktop ~ $ monitor -u ricciocri
Password: 

Successfully logged in...
AuthKey saved to /tmp/.riccio.commands.com.  Delete file to return to Anonymous posting.
monitor$ cd /tmp
...

```

想知道在这之后我使用过的哪个命令吗？我已经把这个会话公开（默认是私有），因此你可以去这个url查看：<https://commands.com/JTNSHRLQJA>


在这里，你能看我已经使用过的命令以及它们的输出，一个有趣的选项是“fold/expand”你可以折叠（fold）所有的命令的输出或者仅仅展开（expand）你喜欢的那个命令的输出。


### 总结


这只是一个简单的安装指南，在这个网站上你能参加更多“社会化”的活动，比如评论脚本/shell会话，派生它们或者选择你的最爱。


和github一样，你能派生任何一个公开的脚本/命令并能直接在网站上改变它，然后你也能得到一个公开（或私有）的url。你可以直接运行你脚本，就像这样：



```
curl commands.io/JTNSHRLQJA | sh

```

在网络上储存一些你在电脑/服务器上经常使用到的脚本，这是极好的，通常不要放置任何密码或敏感信息，这样你的信息才足够安全。




---


via: <http://linuxaria.com/article/how-to-share-on-linux-the-output-of-your-shell-commands>


译者：[guodongxiaren](https://github.com/guodongxiaren) 校对：[Caroline](https://github.com/carolinewuyan)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译，[Linux中国](http://linux.cn/) 荣誉推出


OK
Some time ago I posted an article about [shelr.tv](http://linuxaria.com/recensioni/shelr-broadcast-your-linux-shell-on-the-net) a website and a service that was made to allow you to share your terminal records directly from the website.

Now the website of shelr.tv seems dead and so I’ve took a look around to see if there are similar websites and I’ve found [commands.com](https://commands.com/).

For what I can see from their homepage it’s a service similar to the other, so let’s test it.




### Step 1 – Register on the website

Just [register](https://commands.com/Register/Index) with a new username/password or use your github account to do it quickly.

### Step 2 – download and install the program monitor

[Monitor](https://github.com/dtannen/monitor) is a command-line tool that captures command-line input/output and sends it to commands.com, the program it’s open source and hosted on github.

Monitor makes it easy to automate set-up/install of repos. With it you can easily show at people the most common errors and output from commands.

In short with it you can easily share your commands and their output with the world.

To install it follow these simple steps:

1) Clone the github repository of this project, in this way you’ll get the latest source code.

To do this you need the `git`

command installed on your system, if you get an error with this command install it with your package manager, such as

Debian based distributions:

apt-get install git |


Redhat/Centos/Fedora distributions

yum install git |


And now from a terminal clone the repository with:

git clone https://github.com/dtannen/monitor.git |


2) Install readline and curl, these libraries are a pre-requisite for building the program from the sources:

Debian based distributions:

`apt-get install libreadline-dev libcurl4-openssl-dev` |


Redhat/Centos/Fedora distributions

`yum install readline-devel curl-devel` |


3) Build the program:

To do this you have to go to the directory we just cloned with git and compile the c program:

cd monitor make sudo make install |


The default installation will put the binary in /usr/local/bin

### Step 3 – using the monitor command

The command monitor it’s pretty easy to use:

monitor {-d} {-h} {-u <username>} -d : do not delete /tmp files -h : help -u : commands.com username</username> |


To exit the `monitor`

program you just have to use ctrl-c.

So for me this means just opening a terminal and give these commands:

riccio@mint-desktop ~ $ monitor -u ricciocri Password: Successfully logged in... AuthKey saved to /tmp/.riccio.commands.com. Delete file to return to Anonymous posting. monitor$ cd /tmp ... |


Want to see which command I’ve used after these ?

I’ve made this session public (the default it’s private) so you can simply check this url: [https://commands.com/JTNSHRLQJA](https://commands.com/JTNSHRLQJA)

From there you can see the commands I’ve used and their output, an interesting options it’s the “fold/expand” so you could fold all commands and just expand the output of the one you like more.

### Conclusions

This is just the a basic startup guide, from the website you can make more “social” activity such as comment script/shell sessions, fork them or choose your favorites.

Like github, you can fork any public script/command and change it directly from the website and after that you can also get a public (or private url) that you can use to run directly your script with something like this:

curl commands.io/JTNSHRLQJA | sh |


That’s great to store on the net some scripts that you run frequently on different computers/server, as usual don’t put anything with passwords or sensible information on the net and you’ll be safe enough.



### Popular Posts:

- None Found

One of the differences between “monitor” and the standard linux “script” command is that monitor will capture diff’s from vi edits and add them to the shell script as a patch. Monitor will also filter out garbage characters that are normally present when running the “script” command. Monitor is meant as a 1-stop shop to capture, upload and share on the web and not a replacement for the linux script command.

try “wgetpaste”, it will redirect everything from STDIN to pastebin or similar service