Go to main content
Oracle® ZFS Storage Appliance 관리 설⁠명⁠서, 릴⁠리⁠스 OS8.6.x

인쇄 보기 종료

업데이트 날짜: 2016년 9월
 
 

Children 함수 사용

정적 자식 항목이 있는 컨텍스트에서도 이러한 자식 항목을 프로그래밍적으로 반복하면 유용할 수 있습니다. 이렇게 하려면 정적 자식 항목 배열을 반환하는 children 함수를 사용합니다.

  1. 예를 들어, 다음은 서비스 상태를 인쇄하며 모든 서비스를 반복하는 스크립트입니다.
    configuration services
    script
           var svcs = children();
           for (var i = 0; i < svcs.length; ++i) {
                    run(svcs[i]);
                    try {
                            printf("%-10s %s\n", svcs[i], get('<status>'));
                    } catch (err) { }
                    run("done");
           }
  2. 이름이 "svcinfo.aksh"인 파일에 저장된 경우 스크립트를 실행하면 출력이 다음과 같습니다.
    % ssh root@koi < space.aksh
    Password: 
    cifs       disabled
    dns        online
    ftp        disabled
    http       disabled
    identity   online
    idmap      online
    ipmp       online
    iscsi      online
    ldap       disabled
    ndmp       online
    nfs        online
    nis        online
    ntp        online
    scrk       online
    sftp       disabled
    smtp       online
    snmp       disabled
    ssh        online
    tags       online
    vscan      disabled