Top
Systemwalker Operation Manager  Reference Guide
FUJITSU Software

15.5 Examples of Script Debugging

This section describes the debugging of Systemwalker Scripts using the following two examples.

Example of Embedding a Command Used for Debugging

Below is an example of "15.3 Commands Used in Debugging" that have been embedded in a script.

Example: A script that reads a file given by an argument

Script file

Level (Note)

Output contents

# Open trace file.
  # Delete "level 2" when the script actually runs.
  set Trchwnd [sw_TcOpenTrace -level 2 /var/log/G001]
  if {$Trchwnd < 0} {
        puts stderr "Trace open err"
        exit 1
  }
  # Output a start log record.
  sw_TcWriteTrace $Trchwnd "JOB001 START"
  # Acquire file name.
  set filename [lindex $argv 0]
  sw_TcWriteTrace -level 2 $Trchwnd "Input file name: $filename"
  # Open operation control file.
  if {[catch {
        set cid [open $filename r]
        }]} {
        # When an open error is captured,
        # output an error log record.
        sw_TcWriteTrace $Trchwnd "File open err (filename :$filename)"
        sw_TcCloseTrace $Trchwnd
        exit 1
  }
  sw_TcWriteTrace -level 2 $Trchwnd "File opened "
  # Load file.
  set rc [gets $cid buf]
  if {$rc == -1} {
        # Since the file is empty, set the default in the read buffer.
        sw_TcWriteTrace -level 2 $Trchwnd "File empty "
        set buf 100
  }
  sw_TcWriteTrace -level 2 $Trchwnd "Gets data: $buf"
  close $cid
  ...
  # Output an end log record.
  sw_TcWriteTrace $Trchwnd "JOB001 END"
  sw_TcCloseTrace $Trchwnd







1


2






1




2





2


2



1







Operation log


Information in script
(Route check)




Error log




Route check





Route check


Information in script
(Route check)

Operation log
Note:

The numbers in the "Level" column indicate trace levels.

Since the trace level defaults to 1, its specification in commands is omitted.

Example of How to Change the Trace Level

To specify the trace level, use options of extended trace commands that are entered in Systemwalker Scripts. It is difficult to directly change the content of a script if the trace level needs to be changed when the script is running on Systemwalker Operation Manager. Thus, the following means is provided to allow you to change the trace level without changing scripts.