NOS 120 Final Chap sol 6-10

¡Supera tus tareas y exámenes ahora con Quizwiz!

Name five data types used by Perl.

The Perl data types discussed in the text include: variables, constants, scalars, numbers, strings, arrays, and hashes.

Your program to calculate values in physics requires working with positive and negative whole numbers between -14,242 and 12,528. What data types would you use to work with these numbers in a C program?

short int

In Perl, strings are surrounded by which of the following? (

single or double quotation marks

A daemon is a _

specialized system process that runs in the background

how can you best ensure the BASH shell is invoked when the script is run?

start w #!/bin/bash

Create a simple function that determines if the string variable, text, contains no characters (is of zero length).

stringtest() { test -z $text echo $? }

which of the following statements enables you to determine if the variable, value, is less than 750?

test $value -lt 750

The script you are creating takes data input to use for updating a file. Before taking the data input, you want the script to verify that the file to be updated, called clients, exists and that the script user has permission to write to that file. Which of the following statements enables you to do this?

test -w clients

which shells enables the use of scripts?

bash, csh, zsh

Name two files that should be modified for security when using NFS

Students should name two out of the following three files: /etc/exports, /etc/hosts.allow, and /etc/hosts.deny.

You colleague is creating an HTML-based Web page and wants the first line to have the largest heading size, and so he uses the tag <LARGEHEAD>. This tag isn't producing the expected result. What tag should he use instead?

<H1>

You are creating a data file for an inventory system. Which of the following is a common file extension to show this is a data file?

.dat

In which of the following files would a system administrator set the default shell used by your account?

/etc/password

Which of the following characters are placed right after a function name when you create a shell function?

()

A programmer in your group has written the following subroutine, which does not work. What is the problem? run sort { if ($a < $b) { -1; } elsif ($a == $b) { 0; } else { +1; } } >

He should replace "run" with "sub."

how can you tell which mail messages are new?

new/unopened messages begin with N or U

What compiler is started by using the g++ command?

the C++ compiler

Which of the following is in the proper format for a character constant?

'C' and 'c'

which of the following are examples of boolean operators used with the test command?

-a for a logical AND, -o for a logical OR

Which of the following is an example of a scalar? (Choose all that apply.)

. $income = 62,859; and b. $lname = "McGregor";

when you create a section name in a man page such as the DESCRIPTION section, what tag should you use just before the section name?

.TH

what script to perform the same actions every log out

.bash_logout

What is a filehandle in Perl?

: A filehandle is used to reference a file in Perl. It is the name for an I/O connection and is used to open, read, write to, or close a file that you are accessing.

Which of the following operators is used to access data in an open file in Perl?

<>

When you make a Web page using HTML, what line do you start with to show that what follows after that line consists of HTML tags?

<HTML>

What is an automatic variable?

An automatic variable is a variable declared inside a function and local to the function in which it is declared.

Name at least one difference between Perl and Awk programming.

Awk does not require explicitly setting up looping structures. Awk uses fewer lines of code for pattern-matching extractions. Awk uses BEGIN and END blocks

what command enables echo $CLR?

CLR=`clear`

Which of the following describes Common Gateway Interface (CGI).

It facilitates the exchange of information over the Web. and d. It is a protocol or set of rules.

Name two types of information that you can obtain using netstat

Network protocol communications Network connections established by the host computer Network routing information Information about computers remotely logged onto the host computer Data and communications errors

Which of the following are automatically opened by Perl?

STDOUT and STDERR

What arithmetic operators are used in Perl scripts?

The arithmetic operators used in Perl scripts are + for addition, - for subtraction, * for multiplication, and / for division

One of your colleagues has written a Perl script, but it does not run on some people's computers who use a different Linux distribution or who do not use the Bash shell. Which of the following might be the problem?

The script does not have a beginning line that contains the path to Perl, such as #!/usr/bin/perl.

You have created the following expression in Perl: $value < 2842. What does this expression mean?

The variable value is less than 2842.

Most programmers have to do some debugging of a C or C++ program at some point. Suggest a series of steps to follow when debugging a program

Write down the line number of each error and a brief description. Edit the source file, moving the cursor to the first line number the compiler reports. Within the source file, correct the error, and then move the cursor to the next line number. Most editors display the current line number to help you locate specific lines within the file. After correcting all the errors, save and recompile the file.

which of the following can you restore from a backup tape made via the dump command

a file and a partition of directories and files

What symbol is typically used at the start and end of a flowchart?

a terminator

Which of the following are performed by functions in the C library?

a. screen operations, b. memory allocation operations, c. file operations, and d. math operations

In Perl a variable that starts with $, such as $value, ________________.

can be numeric, nonumeric, and is scalar

What are three examples of looping logic structures that can be used in the C language?

case, for, while

how to change divider from ^ to :

cat customers | tr "^" ";"

In your C program, you want to use a while loop and decrement the value, counter, each time the program goes through the while loop. Which of the following operators enables you to decrement the value in counter?

counter--;

which command enables you to convert the text to uppercase and save result of promotion to promotion_uppercase

dd if=promotion of=promotion_uppercase conv=ucase

Which of the following are examples of symbols you might use in a flowchart?

decision, b. document, c. data, and d. magnetic disk

In Perl, the control sequence \n is used to ________________.

designate a new line.

which command to see if you have enough disk space to store a ton of files

df

what command enables you to obtain disk usage stats?

du -h | more

Your colleague is creating a new man page to document a manufacturing process used by your company. She wants to be able to quickly view the man page as she works on it and so that she can have other people view it before copying the man page into production. Which of the following commands enables her and others to periodically review her work in a format similar to the man page format?

groff

Perl supports using which of the following logic structures?

if statement and while loop

A user on your network has received an error message that there is another computer on the same network using the same IP address, and so the user cannot access the network. You send out a message to the 18 Linux users on your network to ask that they check the IP addresses on their computers and e-mail this information to you, so that you can determine who has the duplicate IP address. What utility do you tell users to run to determine their IP addresses?

ifconfig

When working on the script in Question 15, which of the following should you consider?

input validation

Which of the following are important characteristics of C++ programming?

object-oriented programming and c. use of classes for specialized programming needs

In the following command, what is the purpose of -o? find . "(" -name a.out -o -name core ")"

or operator

You are setting up NFS to share files on the network from your Fedora Linux computer. Which of the following is a service that must be running to enable you to use NFS for sharing files?

portmap

what does a down arrow represent in a flowchart?

process flow

Your computer is slowing down because you've started a process that is taking most of the memory and CPU resources. Which of the following commands enables you to find the process id so you can stop that process?

ps

what is the best way to know what a script is for?

put the name and purpose in the beginning w comments

network has linux + windows. what lets you access shared files from a linux computer over a shared network

samba

Each month your business manually deletes specific records for employees who have left the company. You have been asked to write a script to automate this process. Which of the following commands works well for deleting records in a file?

sed -d

What is the command that you can use (from root) to start the service mentioned in Question 14?

service

You have a small network in your business with just a few network devices connected along with 22 Linux computers and you want to see how efficiently your network is designed. Which of the following commands can you use from different computers to determine the route information takes from one computer to another?

traceroute

how can you specify which device to use for a restore from a backup tape created by the dump command?

use the dump -f option

what command enables you to track how long the server has been up?

utpime

which command enables you to start and run the utility watchit in the background

watchit&

which script statement does the same as while["$part != "alternator"]; do

while test $part != "alternator"; do

what is true about .filetests?

you can load teh file's functions into memory by entering ..filetests, and it is a hidden file

What character shows that you are starting a block of code in the C and C++ languages?

{

When you create a shell function from the command line, what character do you enter at the first > prompt just after you declare the function's name?

{

Which of the following is the right way to use the string constant, Enter your ID:, in the C language?

"Enter your ID:"

Which of the following is an acceptable way to insert a comment line in a C++ program? (Choose all that apply.)

// Program Name: calc.C

which of the following are levels of backups that can be made w the dump command?

0, 5

Your C++ program needs to access the system date in different ways. Which of the following enables you to do this?

<ctime> library

When you assign values for an array, what character should precede the name of the array?

@

In your organization everyone uses the Bash shell in Red Hat Enterprise Linux and all users use the same aliases and shell functions. In what file or files can the system administrator place these aliases and functions so they are available to all users?

In Red Hat Enterprise Linux, the system administrator can place these in the files: /etc/.bashrc and /etc/profile.

You are training a new employee and have been asked to help him learn Perl. Which of the following statements can you use to help describe Perl?

It is popularly used to create reports, such as business reports. and d. It can be used to manipulate text and numeric information

A colleague at work has overheard you discussing the spaceship operator and is curious about what this is. What do you tell him?

It performs numeric sorts in Perl.

You have written the following line in a Perl program: $filein = $ARGV[0];

It saves the name of a file passed from the command line in ARGV[0].

You are gathering information about the amount of disk space occupied by users' home directories. What command enables you to view a breakdown by individual directories under the /home directory? (Provide the actual command you would run and any special considerations for running it.)

The du command provides this information and there are a couple of ways to approach getting the information. One way is to use cd to change to the /home directory and then run a command like, du -h | more. Or from any directory you can run the command du -h /home | more.

What is an exit status and with what command is it used?

The exit status is used with the test command and is a value that represents the results of a test, such a value of 0 to show that the results of the test are true or a value of 1 to show the test results are false.

Name a function that enables you to read the contents of a file and another function that enables you to write to the file in the C language.

The fgetc( ) function is used to read from a file and the fputc( ) function is used to write to a file.

Create a statement that enables you to determine if the file /source/results is newer than the file /data/results

The following statement will test whether the /source/results file is newer: test /source/results -nt /data/results. Or for a complete statement that also shows the exit status, use: test /source/results -nt /data/results ; echo $?

What is the purpose of the top command and how can you use it to stop a process?

The top command enables the user to monitor CPU-intensive tasks, as well as to view processes that are running. It displays the PID for tasks, as well as information such as memory use and other statistics. A process/task can be stopped when you enter the k command and provide the PID.

A new programmer whom you are training is writing a C program and he wants to place comment lines in the program. Which of the following characters should be used at the beginning and end of the comments?

Use /* at the beginning of the comments and */ at the end.

In the following statement, when is "Could not open students file" displayed? open (FILEIN, "students") || warn "Could not open students file \n" ;

When open (FILEIN, "students") is false

how do you make vi automatically set lines in the script?

create the .exrc file in home so that it contains the line: set number

Which of the following are examples of data types in the C language?

int, double, float

Which of the following commands enables you to stop the process mentioned in Question 18?

kill

how to make log in scripts

load them via your login script

Which of the following functions must be in a C program?

main()

You have written a C program using the variables num, enum, sum, and long. When you compile the program you get an error message about using a variable the compiler finds unacceptable. Which of the following is likely to be the problem?

enum and long are keywords and cannot be used as variables

You've written a C program, but are now getting an error message about the use of standard input and output statements when you compile the program. Which of the following might be the cause?

You omitted the preprocessor directive for the file stdio.h

A colleague of yours is just learning to use the C compiler in Linux. When she tries to compile a program called firststart.c using gcc firststart.c she is expecting the executable file to have the name firststart, but there is no firststart file. What is the executable file's name?

a.out

Which of the following statements enables you to print File updated on the screen when a C++ program is finished?

cout << "File updated.\n";

You are writing a Perl script that uses a segment of code over and over again, and you are tired of repeatedly typing in this code. Which of the following should you do?

create a subroutine

Which of the following functions is used to open a file in the C language?

fopen()

What started as a simple C program has now turned into several program modules as you have refined it over the past several months. The problem is that now you do not always remember which modules you have changed at what time. What should you do?

Use the make utility and create makefiles.

The programmer you are training wants to write code to determine when the end of a file has been reached. Which of the following can he use?

feof()

what command enables you to see memory usage by program?

free

Your colleague is writing a Perl script and wants to determine if two strings are the same. He is used the = operator, but it is not working properly. What is the problem?

he should use the eq operator instead

when you enter test -d tmp ; echo $?, you see a 0 displayed on the screen. what does that mean?

the tmp file exists


Conjuntos de estudio relacionados

Human Physio Ch. 12 Muscle Physiology

View Set

Olds Maternal-Newborn nursing ch 4

View Set

Principles of Marketing: Exam 2 Ch 6

View Set

Digestive System Study Guide Ch. 15

View Set

CHEM 101 Ch 3 - Molecules, Compounds, and Atoms

View Set