UpFront

The UpFront Section

UpFront

Tech Tip

If you often have multiple putty, terminal, ssh or screen sessions connected to various remote servers, one good way to organize them is to have a small script that places the name of the remote server in the title bar:

#!/usr/bin/perl -w

$name = $ARGV[0];
unless ($name) { $name = `/bin/hostname` }
print "\033]0;$name\007";

Save this, and make it executable. If, for example, you save it as name, you simply can run name to place the name of the current server in the title bar of your current session.

If you want to label the session with something besides the hostname of the server, just specify the label on the command line:

# name "Mail Server"

Tech Tip

Most Linux distros come packed with documentation in the /usr/share/doc directory, but rarely is there an easy way to get an overview of what's there. The following script creates a master index of all the index.html files in /usr/share/doc and outputs it as index.html in the user's home directory:


#!/bin/bash

input_dir=/usr/share/doc
output_file=~/index.html

cat >$output_file <<EOF
<html>
<head>
<title>$input_dir</title>
</head>
<body>
EOF

find $input_dir -iname 'index.html' | \
    sed 's/[^ ]*/\<br\>\<a href="file:&"\>&\<\/a\>/' \
    >> $output_file

cat >>$output_file <<EOF
</body>
</html>
EOF

Tech Tip

The script command is used to log an entire session. Type the command script at the command prompt, and script then copies everything you type and its response to the file typescript. Script starts a sub-shell; when you want to stop saving the session, end the sub-shell (normally with Ctrl-D or by typing exit).

A very useful feature of the script command is that it can output timing information to a separate file. The script and the timing information then can be used to replay the script.

The following example creates a script and timing data (timing data is always written to standard error):

$ script -t 2> timinginfo
Script started, file is typescript
$ ls
Desktop     test     scripts     redbooks
$ pwd
/home/jagadish
$ hostname
homepc
$ exit
exit
Script done, file is typescript

The entire terminal session then can be replayed later (with exact timing) using the scriptreplay command:

$ scriptreplay timinginfo
$ ls
Desktop     test     scripts     redbooks
$ pwd
/home/jagadish
$ hostname
homepc
$ exit
exit

Script is a useful tool for training and educational purposes.

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState