Sun Java Solaris Communities My SDN Account Join SDN
 
Solaris

LinCAT: Using Scriptran for Script Compatibility

 

January 2004

Overview

The scriptran utility scans your shell scripts and reports compatibility issues caused by differences between Linux and the Solaris OS.

Passing shell scripts through the scriptran filter can identify most issues.

How Scriptran Works

Scriptran scans Bourne shell scripts looking for calls to system commands. Each command is checked for the following conditions:

  • Command is unavailable on the Solaris OS.
  • Command is in a different location and the location is not in the user's path.
  • Command uses a flag that does not exist on the Solaris OS.
  • Command uses a flag that has different functionality on the Solaris OS than in Linux.
  • Output of a command is different and is redirected.

Guide to Using Scriptran

To invoke scriptran, go to the directory containing the scripts to be scanned, then type:

scriptran [options] [filename]

The options are:

--verbose (Get detailed messages.)
--show-all-commands (Show all commands in the shell script -- even those 
	that do not have any issues.)
--show-always (Some shell commands do not have an issue unless specific 
	command line-options are used. By default, scriptran does not report 
	an issue for these commands, unless these options are used. Specifying 
	the --show-always option causes scriptran to report these issues anyway.)
--help | --flags (Display usage information.)

If file name is omitted, scriptran runs in interactive mode.

Using Scriptran in Batch

The scriptran utility is normally used in batch mode. In this mode, scriptran loads the specified file and looks for compatibility issues.

scriptran filename

If the command is found in the issues database, the command is flagged. The output which is sent to stderr will contain a "best guess" as to the current line number containing the issue.

Interactive Mode

Interactive mode lets you check commands as you type them. This is handy if you want to know if there are any porting issues for a specific command. Here is a sample interactive session:

% scriptran
scriptran-cmd (ctrl-d quits) >cat
scriptran:1 *** SCRIPT ISSUE (cat) ***
Issue:
   cat (1) - concatenate files and print on the standard output
   cat on Solaris does NOT have these options:
   -s (different meaning) -A -E (using -e) -T and options
   preceded with --
*** END ISSUE ***
scriptran-cmd (ctrl-d quits) >^D
%

(To end the session, press <Ctrl+d>.)

Common Issues and Workarounds

Here is a list of the most common issues:

Variables are not assigned, so the following will produce a "command not found" error:

	$ BIN=/usr/bin
	$ $BIN/echo

The line number produced is incorrect for lines such as the following that contain sub-shell processing:

$ PROCESSES=`ps -ef | grep -v $USER'

Back to Top

Contents
Previous
Next

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.