Snapdrive for Unix
日本語は機械翻訳による参考訳です。内容に矛盾や不一致があった場合には、英語の内容が優先されます。

スクリプトの例

共同作成者

以下は、終了ステータス値を使用するスクリプトの例です。

次のスクリプトでは、 SnapDrive for UNIX の終了ステータス値を使用します。

	#!/bin/sh
	# This script demonstrates a SnapDrive
	# script that uses exit codes.

	RET=0;
	#The above statement initializes RET and sets it to 0

	snapdrive snap create -dg vg22 -snapname vg22_snap1;
	# The above statement executes the snapdrive command

	RET=$?;
	#The above statement captures the return code.
	#If the operation worked, print
	#success message. If the operation failed, print
	#failure message and exit.

	if [ $RET -eq 0 ]; then
	echo "snapshot created successfully"
	else
	echo "snapshot creation failed, snapdrive exit code was $RET"
	exit 1
	fi
	exit 0;

RET =0 の場合、コマンドは正常に実行され、スクリプトは次のように出力します。

	# ./tst_script
	snap create: snapshot vg22_snap1 contains:
	disk group vg22 containing host volumes
	lvol1
	snap create: created snapshot betty:/vol/vol2:vg22_snap1
	snapshot created successfully

RET = 0 以外の値の場合、コマンドは正常に実行されませんでした。次の例は、一般的な出力を示しています。

	# ./tst_script
	0001-185 Command error: snapshot betty:/vol/vol2:vg22_snap1 already
	exists on betty:/vol/vol2.
	Please use -f (force) flag to overwrite existing snapshot
	snapshot creation failed, snapdrive exit code was 4