open.itworld.com
  Search  
Security Home Page Security Webcasts Security White Papers Security Newsletters Security News Open Topics Careers ITworld Voices ITwhirled The Security site of ITworld.com

Unix Tip: Taking notes the easy way

ITworld.com 4/18/2007

Sandra Henry-Stocker, ITworld.com

Send in your Unix questions today! | See additional Unix tips and tricks

If you ever find yourself cutting and pasting Unix commands and their output into a file in order to create a record of some anomaly you have encountered on a system you manage or to document a procedure so that someone else can take charge while you are on vacation, you may have overlooked a handy command that takes all the fuss out of recording the content of your online session -- the script command.

Invoked without arguments, the script command will open a file named "typescript" and will add to it everything that goes across your terminal window, including what you type and what the system includes in its response.

If you would like to use a different file name, you simply provide it on the command line following script (e.g., script howto.txt) and the file will be created with the provided name. If you already have a file and would like to append to the end of it, script has an option (-a) for doing so.

Script continues collecting commands and output until you enter a ^D (for Bourne, bash, etc.) or exit command. Verify which works with your favorite shell before deciding on your favorite exit technique.

The script command was probably used by early Unix users as a way to easily create a script. They could invoke script, type their commands while capturing them and, at the same time verify that they worked as expected. Of course, they would then have to go back and remove the command output, leaving only the command themselves, and make the new script file executable. Even so, by the time they were done typing the commands, they would have known whether they had built a script that was going to do what they needed.

The script command is a very useful command when you need to collect error messages and other details of some hardware or software failure that you might need to send to someone else for analysis. One of the most frustrating parts of being on the receiving end of error reports is how imprecise many people are when they describe problems that they have encountered. If you can collect both the exact errors that are generated and the context in which they are generated, you will have a much easier time getting the help that you need.

Similarly, if you can train your users to use script to collect the data that you will need in diagnosing problems that they are having, you may not have to call them back to ask exactly what they are seeing and under what circumstances.

Consider using script when you are troubleshooting a difficult problem and you just might need before and after system snapshots to piece together a root cause report once everything is working again. When you are busy probing in numerous directions to pin down what might be wrong, you may not be in a state of mind to record every step that you take (since many, if not most, will not pan out) unless it's relatively painless to do so.

The script command can be very useful, but you must be wary of some screen events -- such as cursor movements used in vi -- that can make script's output files nearly impossible to view.

On this topic

 

Sandra Henry-Stocker has been administering Unix systems for more than 18 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She currently works for TeleCommunication Systems, a wireless communications company, in Annapolis, Maryland, where no one else necessarily shares any of her opinions. She lives with her second family on a small farm on Maryland's Eastern Shore. Send comments and suggestions to bugfarm@gmail.com.




Sponsored Links

Sign up for a Microsoft Dynamics® CRM WEBCAST
Hear globally recognized leaders in customer strategy discuss the importance and evolution of CRM.
Sun Microsystems' - FREE 60 DAY TRIAL OFFER!
Test Sun's Newest Servers BEFORE YOU BUY. Plug Them In With Access To Full Technical Support.
100% Web Based Help Desk Software
Easy to use, customizable to meet your needs, powerful and scalable. Free online demo. Try it today!
Sign up for a Microsoft Dynamics® CRM WEBCAST
Hear globally recognized leaders in customer strategy discuss the importance and evolution of CRM.
Used and Refurbished HP ProCurve Switches
Lifetime Warranties, Professional Testing & Shipping on all HP Equipment Purchases!
» Buy a link now

Advertisements
Sponsored links
Locate Hidden Software on business PCs with this free tool
Bring harmony to your mix of UNIX-Linux-Windows computing environments
Top 5 Reasons to Combine App Performance and Security
KODAK i1400 Series Scanners stand up to the challenge
 Home   Open source  Operating systems  Unix
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.