ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Shell Scripting
    IoT 과정 2017. 7. 5. 12:23
    반응형

    Unix Shell Family tree

    Thompson Shell 1971

    |_ Bourne (sh) 1977 관리자 기능에서 유용했음

       |_ Korn (ksh) 1983 csh과 ksh의 장점 믹스

    |_ Korn (ksh93) 1993 이 때 POSIX Shell이 HPUX의 표준이됨

       |_ Bourne-Again (bash) 1987

    |_ Cshell (csh) 1978 자동 완성기능 등 프로그래머들 유용한 커맨드 많음


    Which Shell Interprects the Script?  Hash #, bang ! and absolute path

    #!/usr/bin/sh    Interpret using the POSIX Shell

    #!/bin/sh         Interpret using the POSIX Shell ...

    #!/bin/csh        ... C Shell...


    Recommended Script Format

    First Line - Specify the interpreter

    Header - Brief description of the script

    Body - Commands to be executed

    Last Line - exit# , # is return value


    How HP-UX Uses Shell Scripts

    1 At system start-up(boot) time

    2 At system shutdown

    3 As commands


    실습

    1

    $ vi sysinfo.sh

    "sysinfo.sh" 1 line, 45 characters

    echo "hostname of this machine: $(hostname)"

    print "Operating system : $(uname -s)"

    print "OS version: $(uname -r)"

    $ sysinfo.sh
    hostname of this machine: vm161
    Operating system : HP-UX
    OS version: B.11.31


    2
    $ cat random.sh
    #!/usr/bin/sh
    # random.sh
    # print some info, then a random number

    print "executing random.sh"

    print "Today is" $(date)

    print "Followin is a random number:  $RANDOM "

    exit

    $RANDOM 변수는 POSIX Shell 에 의해 결정된다. 확인 방법 $ man sh -> see also -> $ man sh-posix
    -> /RANDOM/ 검색

    RANDOM         Each time this parameter is evaluated, a random
                         integer, uniformly distributed between 0 and 32767, is  //2^15 = 32768, 15bit
                         generated.  The sequence of random numbers can be
                         initialized by assigning a numeric value to RANDOM.

    반응형

    'IoT 과정' 카테고리의 다른 글

    User Input  (0) 2017.07.05
    Variable  (0) 2017.07.05
    Shell Scripting  (0) 2017.07.05
    POSIX Shell Programming  (0) 2017.07.05
    HPUX - Managing Users and Groups  (0) 2017.06.26
    HPUX - Shell Programming - Loops  (0) 2017.06.23

    댓글 0

Designed by Tistory.