| by Arround The Web | No comments

Using Seashells to display terminal output to a web browser

Introduction

Having the ability to display your terminal output to a web browser would be a neat feature to have. In this article, we will be discussing a tool named Seashells that does exactly that. Seashells lets you pipe output from command-line programs to the web in real-time, even without installing any new software on your machine.  You can use it to monitor long-running processes that produce continuous output to the console.  You can also use Seashells to share output with friends! Seashells is actually a client to Seashells.io website.  You can either use Seashells.io directly or just install the Seashells client to pipe your output.

Some things to keep in mind before getting started:

  • Seashells is still in beta phase and therefore should not be used on production systems.
  • It does not act as a medium to store session data long term. All old sessions (links) will be deleted after a day.
  • Seashells does not have any user account/registration system yet and uses your system’s IP address to identify it and each IP address is limited to 5 concurrent sessions.

Using Seashells.io

If you wish to use the Seashells.io website directly then you don’t need to install anything on your system.
The system you are working with needs to have a connection to the internet and must have the netcat package installed. Along with that the port 1337 should be open on the system. Let’s verify that our system does in fact have netcat installed.

[root@linuxnix ~]# which nc
/bin/nc
[root@linuxnix ~]# yum whatprovides $(which nc)
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.0x.sg
* epel: mirror.nes.co.id
* extras: mirror.0x.sg
* nux-dextop: mirror.li.nux.ro
* updates: mirror.0x.sg
2:nmap-ncat-6.40-13.el7.x86_64 : Nmap's Netcat replacement
Repo : @base
Matched from:
Filename : /bin/nc

Now we can type commands on the terminal and then pipe their output to the Seashells.io site by connecting to it on port 1337 using netcat. Given below is an example:

[root@linuxnix ~]# echo 'Hello World! My name is Sahil' | nc seashells.io 1337
serving at https://seashells.io/v/8Ef9eYnz
[root@linuxnix ~]#

The URL in the output is where the output from our command was redirected to. If we open a browser tab and type in the URL we will see the output of the command we typed being redirected on the screen.

Using Seashells client

If you intend to use Seashells frequently then it is advisable to install the Seashells client instead of relying on netcat.
Seashells is written in Python and it supports both Python 2.x and Python 3.x. Being a python package we can install Seashells on our system using the pip utility.

[root@linuxnix ~]# pip install seashells
Collecting seashells
Downloading https://files.pythonhosted.org/packages/17/f0/7b792f7eb1ead8a798e2da4f14ca3d661854d8df8922f7bfc6a0734f0cd1/seashells-0.1.2-py2.py3-none-any.whl
Installing collected packages: seashells
Successfully installed seashells-0.1.2

Now that we have the Seashells client installed we do not need to use the netcat utility and can pipe the output of our commands directly to the Seashells client tool. Also, we can use commands generating output that gets updated while the command is still executing. The top command is a good example so let’s use that:

[root@linuxnix ~]# top | seashells
serving at https://seashells.io/v/y88abKYc
top - 20:15:02 up 22:48, 3 users, load average: 0.00, 0.01, 0.05
Tasks: 114 total, 1 running, 113 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.5 us, 0.2 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1865988 total, 1119040 free, 163472 used, 583476 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 1490252 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
903 root 20 0 303172 6268 4684 S 0.3 0.3 3:36.92 vmtoolsd
12377 root 20 0 157700 2196 1536 R 0.3 0.1 0:00.43 top
12378 root 20 0 185872 8168 3620 S 0.3 0.4 0:01.81 seashells
------------------output truncated for brevity

If we open our browser and type the URL displayed in the output we will observe the output of the top command being displayed.

Conclusion

In this article, we demonstrated how we could use the Seashells website directly and the Seashells client tool to pipe out our command line output from the terminal of our local system directly to the web. We hope that you’ve found this article to be useful and we look forward to your feedback and suggestions.

The post Using Seashells to display terminal output to a web browser appeared first on The Linux Juggernaut.

Share Button

Source: The Linux Juggernaut

Leave a Reply