July 23, 2013

Unix command: script

What is "script" command?

script is a very useful command that can be used to capture all that appears on a terminal. The output thus captured from the interactive session may then be useful while sharing with another colleague or team, or even used in a variety of debugging scenarios.

Next time you find yourself in a position to grab the screen/terminal contents, make use of this wonderful utility instead of relying on ad-hoc output redirections and screenshot captures.

What is its syntax and how do I use it?

Refer to the man pages on your system for the exact syntax/details, or an online resource like the one at http://unixhelp.ed.ac.uk/CGI/man-cgi?script. Typical usage however is along the lines of:
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]

Are there any interesting points to be noted?

One standard note is that interactive commands, such as vi, create garbage in the output file. Be aware of it as such and use "script" for capturing plain text.

Few oft missed aspects, though, are that it:
  • Invokes a new shell based on what is populated in the environment variable SHELL
  • Creates a new login session as can be seen from the output of last command

Why don't you show me a simple invocation and what does it result in?

Sure, I can :)

Here's a sample invocation of the command:
sh-3.2# script
Script started, file is typescript
sh-3.2# ls
bin  boot  dev  etc  home  lib  lib64  lost+found  media  misc  mnt  net  opt
proc  root  sbin  selinux  srv  sys  tftpboot  tmp  typescript  usr  var
sh-3.2# exit
exit
Script done, file is typescript
And, this is what is logged into the file:
sh-3.2# cat typescript
Script started on Tue 23 Jul 2013 04:10:04 PM IST
sh-3.2# ls
bin  boot  dev  etc  home  lib  lib64  lost+found  media  misc  mnt  net  opt
proc  root  sbin  selinux  srv  sys  tftpboot  tmp  typescript  usr  var
sh-3.2# exit
exit

Script done on Tue 23 Jul 2013 04:10:20 PM IST
sh-3.2# 

July 9, 2013

MobaXterm

I wanted to include a one-liner in the title of this Techbit than just the tool name i.e. MobaXterm - it was very difficult though. There are so many wide-ranged features integrated into one single app.

Listed below are some of the features/findings:
  1. Tabbed Console with UNIX-like interface – replacement for Console & accommodates part of Cygwin
  2. Tabbed Console with support for embedded terminal server sessions – replacement for PuTTY Connection Manager
  3. X-server client – replacement for X-based commercial tools like Exceed or Reflection-X
  4. Multi-Execution Mode – you want the same command to be invoked in parallel on several servers? Then, this is what you want.
  5. Ability to download files (SFTP/FTP) from the terminal session – In general, if you want to fetch a file while working on a terminal server session, then you open a separate file transfer app (like FileZilla) and then download it. This can all be done from the same session in this tool.
MobaXterm is free and available for download at http://mobaxterm.mobatek.net/.