Skip to main content
Snapdrive for Unix
본 한국어 번역은 사용자 편의를 위해 제공되는 기계 번역입니다. 영어 버전과 한국어 버전이 서로 어긋나는 경우에는 언제나 영어 버전이 우선합니다.

스크립트 예제

기여자 netapp-ivanad

다음은 종료 상태 값을 사용하는 스크립트의 예입니다.

다음 스크립트는 UNIX 종료 상태 값에 SnapDrive를 사용합니다.

	#!/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