16.6.2.12.22 End while loop and shell exits

16.7 Quiz

  1. Use the following example for the questions in this topic.
    #!/usr/bin/ksh
    #
    # If srcmstr is running, ensure that it is active before issuing the
    # startsrc commands
    #
    if [ -n "$src_running"];then
    echo "Checking for srcmstr active...\c"
    i=10 # try ten times to contact it
    while [ $i != 10 ] ; do
    lssrc -s inetd >/dev/null 2>&1 && break # break out on success
    sleep 1
    echo ".\c"
    i='expr $i -1'
    done
    if [ $i=0 ];then
    echo "\n\n ERROR:srcmstr is not accepting connections.\n"
    exit 1
    fi
    echo "complete"
    
    else
    src_running=""
    fi
    

    In the above section of code, what is the problem?

    A.
    The while loop is never executed.
    B.
    There are no break statements in the loop.
    C.
    The variable i should be initialized to zero.
    D.
    The while loop does not have the done statement.

  2. A marketing manager would like her shell prompt to reflect the directory she is in so that she needs to remove a file, she will be sure to be in the proper directory. Which of the following environment variables can be set to accomplish this?
    A.
    PS1
    B.
    PATH
    C.
    DISPLAY
    D.
    LOCPATH

  3. A client has changed their personal .profile to allow for a search of the /usr/local/bin filesystem. This was needed to test new software on the development machine. The client will be going production with the new software the next weekend, impacting about 500 users. Which of the following should be recommended to the client in order to avoid any potential problems?
    A.
    modify /etc/hosts to allow the production users to use the software
    B.
    modify /etc/profile to allow the production users to use the software
    C.
    modify /etc/hosts.equiv to allow the production users to use the software
    D.
    modify /etc/resolv.conf to allow the production users to use the software}

16.7.1 Answers

  1. A
  2. A
  3. B

16.8 Exercises