This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
magicka/deps/cdk-5.0-20161210/cli/samples/matrix.sh
2017-03-20 21:40:32 +10:00

124 lines
2.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# $Id: matrix.sh,v 1.4 2005/12/27 17:07:00 tom Exp $
#
# Description:
# This demonstrates the CDK command line
# interface to the matrix widget.
#
#
# Create some global variables.
#
CDK_MATRIX="${CDK_BINDIR=..}/cdkmatrix"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"
fileSystemList="${TMPDIR=/tmp}/fsList.$$"
info="${TMPDIR=/tmp}/fsInfo.$$"
diskInfo="${TMPDIR=/tmp}/diskInfo.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
#
# Get the filesystem information.
#
getDiskInfo()
{
fileName=$1;
command="df"
#
# Determine the type of operating system.
#
machine=`uname -s`
if [ "$machine" = "SunOS" ]; then
level=`uname -r`
if [ "$level" -gt 4 ]; then
command="df -kl"
fi
else
if [ "$machine" = "AIX" ]; then
command="df -i"
fi
fi
#
# Run the command.
#
${command} > ${fileName}
}
#
# Get the disk information.
#
getDiskInfo ${diskInfo}
#
# Create the row titles.
#
rowTitles=`tail +2 ${diskInfo} | awk '{printf "%s\n", $1}'`
#
# Create the column titles.
#
colTitles="KBytes
Used
Avail
Capacity
Mounted on"
#
# Define the matrix title.
#
title="<C></U>Current Filesystem Information"
#
# Create the data file to fill in the matrix.
#
tail +2 ${diskInfo} | awk '{printf "%s%s%s%s%s\n", $2, $3, $4, $5, $6}' > ${info}
#
# Set the widths of the columns.
#
colWidths="5
5
5
5
5"
#
# Set the cells as uneditable.
#
types="VIEWONLY
VIEWONLY
VIEWONLY
VIEWONLY
VIEWONLY"
buttons=" OK
Cancel "
#
# Start the matrix.
#
${CDK_MATRIX} -r "${rowTitles}" -c "${colTitles}" -v 3 -w "${colWidths}" -d "${info}" -t "${types}" -T "${title}" -B "${buttons}" -O"$tmp"
selected=$?
test $selected = 255 && exit 1
#
# Create the message for the label widget.
#
echo "<C>You chose button #${selected}" > ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}
#
# Create the label widget to display the information.
#
${CDK_LABEL} -f "${tmp}" -p " "
#
# Clean up.
#
rm -f ${info} ${fileSystemList} ${tmp} ${diskInfo}