1. Trang chủ
  2. » Ngoại Ngữ

solaris 9 user command phần 9 pptx

72 341 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Solaris 9 User Command Phần 9 PPTX
Trường học University of the People
Chuyên ngành Computer Science
Thể loại lecture notes
Năm xuất bản 2023
Thành phố Los Angeles
Định dạng
Số trang 72
Dung lượng 566,26 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

example% tput cup 23 4 The next command prints the long name from the terminfo database for the type ofterminal specified in the environment variable TERM.. When the -d option is not spe

Trang 1

touch – change file access and modification times

/usr/ucb/touch [-acfm] file…

touchsets the access and modification times of each file to the current time file iscreated if it does not already exist

-a Change the access time of file Do not change the modification time

unless -m is also specified

-c Do not create file if it does not exist

-f Attempt to force the touch in spite of read and write permissions on file.-m Change the modification time of file Do not change the access time

unless -a is also specified

See largefile(5) for the description of the behavior of touch when encounteringfiles greater than or equal to 2 Gbyte ( 231bytes)

The following exit values are returned:

0 touchexecuted successfully and all requested changes were made

>0 An error occurred touch returns the number of files for which the times

could not be successfully modified

See attributes(5) for descriptions of the following attributes:

Trang 2

tplot, t300, t300s, t4014, t450, tek, ver – graphics filters for various plotters

/usr/bin/tplot [-T terminal]

tplotreads plotting instructions from the standard input and produces plotting

instructions suitable for a particular terminal on the standard output.

If no terminal is specified, the environment variable TERM is used The default terminal

is tek

Except for ver, the following terminal-types can be used with ‘lpr -g’ (see lpr) toproduce plotted output:

300 DASI 300 or GSI terminal (Diablo® mechanism)

300s | 300S DASI 300s terminal (Diablo mechanism)

450 DASI Hyterm 450 terminal (Diablo mechanism)

4014 | tek Tektronix 4014 and 4015 storage scope with Enhanced Graphics

Module (Use 4013 for Tektronix 4014 or 4015 without theEnhanced Graphics Module)

ver Versatec® D1200A printer-plotter The output is scan-converted

and suitable input to ‘lpr -v’

/usr/lib/t300/usr/lib/t300s/usr/lib/t4014/usr/lib/t450/usr/lib/tek/usr/lib/vplotSee attributes(5) for descriptions of the following attributes:

Trang 3

tput – initialize a terminal or query terminfo database

tput [-T type] capname [parm…]

tput -S <<

tputuses the terminfo database to make the values of terminal-dependentcapabilities and information available to the shell (see sh(1)); to clear, initialize or resetthe terminal; or to return the long name of the requested terminal type tput outputs

a string if the capability attribute (capname) is of type string, or an integer if the

attribute is of type integer If the attribute is of type boolean, tput simply sets the exitstatus (0 for TRUE if the terminal has the capability, 1 for FALSE if it does not), andproduces no output Before using a value returned on standard output, the usershould test the exit status ($?, see sh(1)) to be sure it is 0 See the EXIT STATUSsection

The following options are supported:

-Ttype Indicates the type of terminal Normally this option is

unnecessary, because the default is taken from the environmentvariable TERM If -T is specified, then the shell variables LINESand COLUMNS and the layer size will not be referenced

-S Allows more than one capability per invocation of tput The

capabilities must be passed to tput from the standard inputinstead of from the command line (see the example in theEXAMPLESsection) Only one capname is allowed per line The -S

option changes the meaning of the 0 and 1 boolean and string exitstatuses (see the EXIT STATUS section)

The following operands are supported:

capname Indicates the capability attribute from the terminfo database See

terminfo(4) for a complete list of capabilities and the capname

associated with each

The following strings will be supported as operands by theimplementation in the "C" locale:

clear Display the clear-screen sequence

init If the terminfo database is present and an

entry for the user’s terminal exists (see -Ttype,

above), the following will occur:

1 if present, the terminal’s initializationstrings will be output (is1, is2, is3, if,iprog),

2 any delays (for instance, newline) specified

in the entry will be set in the tty driver,

Trang 4

3 tabs expansion will be turned on or offaccording to the specification in the entry,and

4 if tabs are not expanded, standard tabs will

be set (every 8 spaces) If an entry does notcontain the information needed for any ofthe four above activities, that activity willsilently be skipped

reset Instead of putting out initialization strings, the

terminal’s reset strings will be output if present(rs1, rs2, rs3, rf) If the reset strings are notpresent, but initialization strings are, theinitialization strings will be output Otherwise,resetacts identically to init

longname If the terminfo database is present and an

entry for the user’s terminal exists (see -Ttype

above), then the long name of the terminal will

be put out The long name is the last name inthe first line of the terminal’s description in theterminfodatabase (see term(5))

parm If the attribute is a string that takes parameters, the argument parm

will be instantiated into the string An all numeric argument will

be passed to the attribute as a number

EXAMPLE 1Using the tput command

This example initializes the terminal according to the type of terminal in the

environment variable TERM This command should be included in everyone’s profileafter the environment variable TERM has been exported, as illustrated on the

profile(4) manual page

example% tput init

The next example resets an AT&T 5620 terminal, overriding the type of terminal in theenvironment variable TERM:

example% tput -T5620 reset

The following example sends the sequence to move the cursor to row 0, column 0 (theupper left corner of the screen, usually known as the "home" cursor position)

example% tput cup 0 0

The next example echos the clear-screen sequence for the current terminal

example% tput clear

The next command prints the number of columns for the current terminal

example% tput cols

The following command prints the number of columns for the 450 terminal

tput(1)

EXAMPLES

Trang 5

EXAMPLE 1Using the tput command (Continued)

example% tput -T450 cols

The next example sets the shell variables bold, to begin stand-out mode sequence,and offbold, to end standout mode sequence, for the current terminal This might befollowed by a prompt:

echo "${bold}Please type in your name: ${offbold}\c"

example% bold=’tput smso’

example% offbold=’tput rmso’

This example sets the exit status to indicate if the current terminal is a hardcopyterminal

example% tput hc

This next example sends the sequence to move the cursor to row 23, column 4

example% tput cup 23 4

The next command prints the long name from the terminfo database for the type ofterminal specified in the environment variable TERM

example% tput longname

This last example shows tput processing several capabilities in one invocation Thisexample clears the screen, moves the cursor to position 10, 10 and turns on bold (extrabright) mode The list is terminated by an exclamation mark (!) on a line by itself

TERM Determine the terminal type If this variable is unset or null, and if the -T

option is not specified, an unspecified default terminal type will be used.The following exit values are returned:

0

If capname is of type boolean and -S is not specified, indicates TRUE.

If capname is of type string and -S is not specified, indicates capname is

defined for this terminal type

If capname is of type boolean or string and -S is specified, indicates that

all lines were successful

capname is of type integer.

■ The requested string was written successfully

Trang 6

If capname is of type string and -S is not specified, indicates that capname is not defined for this terminal type.

3 No information is available about the specified terminal type

4 The specified operand is invalid

>4 An error occurred

−1 capname is a numeric variable that is not specified in the terminfo

database; for instance, tput -T450 lines and tput -T2621 xmc

/usr/lib/tabset/* tab settings for some terminals, in a format

appropriate to be output to the terminal(escape sequences that set margins andtabs); for more information, see the "Tabsand Initialization" section of terminfo(4)/usr/share/lib/terminfo/?/* compiled terminal description databaseSee attributes(5) for descriptions of the following attributes:

Trang 7

tr – translate characters

/usr/bin/tr [-cs] string1 string2

/usr/bin/tr -s | -d [-c] string1

/usr/bin/tr -ds [-c] string1 string2

/usr/xpg4/bin/tr [-cs] string1 string2

/usr/xpg4/bin/tr -s | -d [-c] string1

/usr/bin/xpg4/tr -ds [-c] string1 string2

The tr utility copies the standard input to the standard output with substitution or

deletion of selected characters The options specified and the string1 and string2

operands control translations that occur while copying characters and single-charactercollating elements

The following options are supported:

-c Complements the set of characters specified by string1.

-d Deletes all occurrences of input characters that are specified by string1.

-s Replaces instances of repeated characters with a single character

When the -d option is not specified:

Each input character found in the array specified by string1 is replaced by the character in the same relative position in the array specified by string2 When the array specified by string2 is shorter that the one specified by string1, the results are

unspecified

If the -c option is specified, the complements of the characters specified by string1

(the set of all characters in the current character set, as defined by the current

setting of LC_CTYPE, except for those actually specified in the string1 operand) are

placed in the array in ascending collation sequence, as defined by the currentsetting of LC_COLLATE

■ Because the order in which characters specified by character class expressions orequivalence class expressions is undefined, such expressions should only be used ifthe intent is to map several characters into one An exception is case conversion, asdescribed previously

When the -d option is specified:

Input characters found in the array specified by string1 will be deleted.

■ When the -c option is specified with -d, all characters except those specified by

string1 will be deleted The contents of string2 will be ignored, unless the -s option

is also specified

■ The same string cannot be used for both the -d and the -s option; when both

options are specified, both string1 (used for deletion) and string2 (used for

squeezing) are required

Trang 8

When the -s option is specified, after any deletions or translations have taken place,repeated sequences of the same character will be replaced by one occurrence of thesame character, if the character is found in the array specified by the last operand Ifthe last operand contains a character class, such as the following example:

tr -s ’[:space:]’

the last operand’s array will contain all of the characters in that character class

However, in a case conversion, as described previously, such as

tr -s ’[:upper:]’ ’[:lower:]’

the last operand’s array will contain only those characters defined as the secondcharacters in each of the toupper or tolower character pairs, as appropriate (Seetoupper(3C) and tolower(3C))

An empty string used for string1 or string2 produces undefined results.

The following operands are supported:

string1 string2 Translation control strings Each string represents a set of

characters to be converted into an array of characters used for thetranslation

The operands string1 and string2 (if specified) define two arrays of characters The

constructs in the following list can be used to specify characters or single-charactercollating elements If any of the constructs result in multi-character collating elements,

trwill exclude, without a diagnostic, those multi-character elements from theresulting array

character Any character not described by one of the conventions below

represents itself

\octal Octal sequences can be used to represent characters with specific

coded values An octal sequence consists of a backslash followed

by the longest sequence of one-, two-, or three-octal-digitcharacters (01234567) The sequence causes the character whoseencoding is represented by the one-, two- or three-digit octalinteger to be placed into the array Multi-byte characters requiremultiple, concatenated escape sequences of this type, including theleading \ for each byte

\character The backslash-escape sequences \a, \b, \f, \n, \r, \t, and \v are

supported The results of using any other character, other than anoctal digit, following the backslash are unspecified

tr(1)

OPERANDS

Trang 9

c-c [ c-c ] Represents the range of collating elements between the range

endpoints, inclusive, as defined by the current setting of theLC_COLLATElocale category The starting endpoint must precedethe second endpoint in the current collation order The characters

or collating elements in the range are placed in the array inascending collation sequence

[:class:] Represents all characters belonging to the defined character class,

as defined by the current setting of the LC_CTYPE locale category.The following character class names will be accepted when

given a charclass definition in the LC_CTYPE category

Note: /usr/bin/tr supports character class expressions only in

singlebyte locales Use /usr/xpg4/bin/tr to support theseexpressions in any locale

When both the -d and -s options are specified, any of the

character class names will be accepted in string2 Otherwise, only character class names lower or upper are valid in string2 and

then only if the corresponding character class upper and lower,

respectively, is specified in the same relative position in string1.

Such a specification is interpreted as a request for case conversion

When [:lower:] appears in string1 and [:upper:] appears in string2, the arrays will contain the characters from the toupper

mapping in the LC_CTYPE category of the current locale When[:upper:]appears in string1 and [:lower:] appears in string2,

the arrays will contain the characters from the tolower mapping

in the LC_CTYPE category of the current locale The first character

from each mapping pair will be in the array for string1 and the

second character from each mapping pair will be in the array for

string2 in the same relative position.

Except for case conversion, the characters specified by a characterclass expression are placed in the array in an unspecified order

If the name specified for class does not define a valid character

class in the current locale, the behavior is undefined

[=equiv=] Represents all characters or collating elements belonging to the

same equivalence class as equiv, as defined by the current setting of

the LC_COLLATE locale category An equivalence class expression

tr(1)

/usr/xpg4/bin/tr

/usr/bin/tr

Trang 10

is allowed only in string1, or in string2 when it is being used by the

combined -d and -s options The characters belonging to theequivalence class are placed in the array in an unspecified order

[x*n] Represents n repeated occurrences of the character x Because this

expression is used to map multiple characters to one, it is only

valid when it occurs in string2 If n is omitted or is 0, it is interpreted as large enough to extend the string2-based sequence

to the length of the string1-based sequence If n has a leading 0, it

is interpreted as an octal value Otherwise, it is interpreted as adecimal value

See largefile(5) for the description of the behavior of tr when encountering filesgreater than or equal to 2 Gbyte ( 231bytes)

EXAMPLE 1Creating a list of words

The following example creates a list of all words in file1, one per line in file2, where a

word is taken to be a maximal string of letters

tr −cs "[:alpha:]" "[\n*]" <file1 >file2

EXAMPLE 2Translating characters

This example translates all lower-case characters in file1 to upper-case and writesthe results to standard output

tr "[:lower:]" "[:upper:]" <file1

Notice that the caveat expressed in the corresponding example in XPG3 is no longer ineffect This case conversion is now a special case that employs the tolower andtoupperclassifications, ensuring that proper mapping is accomplished (when thelocale is correctly defined)

EXAMPLE 3Identifying equivalent characters

This example uses an equivalence class to identify accented variants of the basecharacter e in file1, which are stripped of diacritical marks and written to file2

tr "[=e=]" e <file1 >file2

See environ(5) for descriptions of the following environment variables that affect theexecution of tr: LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH

The following exit values are returned:

0 All input was processed successfully

Trang 11

See attributes(5) for descriptions of the following attributes:

Trang 12

tr – translate characters

/usr/ucb/tr [-cds] [string1 [string2]]

The tr utility copies the standard input to the standard output with substitution or

deletion of selected characters The arguments string1 and string2 are considered sets

of characters Any input character found in string1 is mapped into the character in the corresponding position within string2 When string2 is short, it is padded to the length

of string1 by duplicating its last character.

In either string the notation:

a−b

denotes a range of characters from a to b in increasing ASCII order The character \ ,

followed by 1, 2 or 3 octal digits stands for the character whose ASCII code is given bythose digits As with the shell, the escape character \ , followed by any other

character, escapes any special meaning for that character

Any combination of the options -c, -d, or -s may be used:

-c Complement the set of characters in string1 with respect to the universe of

characters whose ASCII codes are 01 through 0377 octal

-d Delete all input characters in string1.

-s Squeeze all strings of repeated output characters that are in string2 to single

characters

EXAMPLE 1Creating a list of all the words in a filename

The following example creates a list of all the words in filename1, one per line, in filename2, where a word is taken to be a maximal string of alphabetics The second

string is quoted to protect ‘ \ ’ from the shell 012 is the ASCII code for NEWLINE

example% tr -cs A−Za−z ’\012’ < filename1> filename2

See attributes(5) for descriptions of the following attributes:

ed(1), ascii(5), attributes(5)

Will not handle ASCII NUL in string1 or string2 tr always deletes NUL from input.

Trang 13

trap, onintr – shell built-in functions to respond to (hardware) signals

trap [argument n [n2…]]

onintr [-| label]

*trap [arg sig [sig2…]]

The trap command argument is to be read and executed when the shell receives numeric or symbolic signal(s) (n) (Note: argument is scanned once when the trap is set

and once when the trap is taken.) Trap commands are executed in order of signalnumber or corresponding symbolic names Any attempt to set a trap on a signal thatwas ignored on entry to the current shell is ineffective An attempt to trap on signal 11

(memory fault) produces an error If argument is absent all trap(s) n are reset to their original values If argument is the null string this signal is ignored by the shell and by the commands it invokes If n is 0 the command argument is executed on exit from the

shell The trap command with no arguments prints a list of commands associatedwith each signal number

onintrcontrols the action of the shell on interrupts With no arguments, onintrrestores the default action of the shell on interrupts (The shell terminates shell scriptsand returns to the terminal command input level) With the− argument, the shell

ignores all interrupts With a label argument, the shell executes a goto label when an

interrupt is received or a child process terminates because it was interrupted

trapuses arg as a command to be read and executed when the shell receives signal(s) sig (Note that arg is scanned once when the trap is set and once when the trap is taken.) Each sig can be given as a number or as the name of the signal trap

commands are executed in order of signal number Any attempt to set a trap on a

signal that was ignored on entry to the current shell is ineffective If arg is omitted or is

−, then the trap(s) for each sig are reset to their original values If arg is the null (the

empty string, e.g., "" ) string then this signal is ignored by the shell and by the

commands it invokes If sig is ERR then arg will be executed whenever a command has

a non-zero exit status If sig is DEBUG then arg will be executed after each command If sig is 0 or EXIT for a trap set outside any function then the command arg is executed

on exit from the shell The trap command with no arguments prints a list ofcommands associated with each signal number

On this man page, ksh(1) commands that are preceded by one or two * (asterisks) aretreated specially in the following ways:

1 Variable assignment lists preceding the command remain in effect when thecommand completes

2 I/O redirections are processed after variable assignments

3 Errors cause a script that contains them to abort

4 Words, following a command preceded by ** that are in the format of a variableassignment, are expanded with the same rules as a variable assignment Thismeans that tilde substitution is performed after the = sign and word splitting andfile name generation are not performed

trap(1)

NAME

sh csh ksh sh

csh

ksh

Trang 14

See attributes(5) for descriptions of the following attributes:

Trang 15

troff – typeset or format documents

troff [-a] [-f] [-Fdir] [-i] [-mname] [-nN] [-olist] [-raN] [-sN]

[-Tdest] [-uN] [-z] [filename…]

troffformats text in the filenames for typesetting or laser printing Input to troff is

expected to consist of text interspersed with formatting requests and macros If no

filename argument is present, troff reads standard input A minus sign (−) as a filename indicates that standard input should be read at that point in the list of input

files

The output of troff is usually piped through dpost(1) to create a printablepostscript file (see EXAMPLES)

The following options are supported They may appear in any order, but all must

appear before the first filename.

-a Send an ASCII approximation of formatted output to standard

output (Note: a rough ASCII version can also be printed out onordinary terminals with an old and rarely used command,/usr/bin/ta.)

-f Do not print a trailer after the final page of output or cause the

postprocessor to relinquish control of the device

-Fdir Search directory dir for font width or terminal tables instead of the

system default directory

-i Read standard input after all input files are exhausted

-mname Prepend the macro file /usr/share/lib/tmac/name to the

input filenames Note: most references to macro packages include the leading m as part of the name; for example, the man(5) macros

reside in /usr/share/lib/tmac/an The macro directory can

be changed by setting the TROFFMACS environment variable to aspecific path Be certain to include the trailing ’ / ’ (slash) at theend of the path

-nN Number the first generated page N.

-olist Print only pages whose page numbers appear in the

comma-separated list of numbers and ranges A range N−M means pages N through M; an initial −N means from the beginning to page N; and a final N− means from N to the end.

-q Quiet mode in nroff; ignored in troff

-raN Set register a (one-character names only) to N.

-sN Stop the phototypesetter every N pages On some devices, troff

produces a trailer so you can change cassettes; resume by pressingthe typesetter’s start button

Trang 16

-Tdest Prepare output for typesetter dest The following values can be

supplied for dest:

post A PostScript printer; this is the default value The

output of the -T option must go through dpost(1)before it is sent to a PostScript printer to obtain theproper output

aps Autologic APS-5

-uN Set the emboldening factor for the font mounted in position 3 to N.

If N is missing, then set the emboldening factor to 0.

-z Suppress formatted output Only diagnostic messages and

messages output using the tm request are output

The following operand is supported:

filename The file containing text to be processed by troff

EXAMPLE 1Using troff

The following example shows how to print an input text file mytext, coded withformatting requests and macros The input file contains equations and tables and must

go through the tbl(1) and eqn(1) preprocessors before it is formatted by troff with

msmacros, processed by dpost(1), and printed by lp(1):

tbl mytext | eqn | troff -ms | dpost | lp

/usr/share/lib/tmac/* standard macro files/usr/lib/font/* font width tables for alternate mounted

trofffonts/usr/share/lib/nterm/* terminal driving tables for nroffSee attributes(5) for descriptions of the following attributes:

Trang 17

Previous documentation incorrectly described the numeric register yr as being the

"Last two digits of current year" yr is in actuality the number of years since 1900 Tocorrectly obtain the last two digits of the current year through the year 2099, thedefinition given below of string register yy may be included in a document andsubsequently used to display a two-digit year Note that any other available one- ortwo-character register name may be substituted for yy

.\" definition of new string register yy last two digits of year \" use yr (# of years since 1900) if it is < 100

.ie \n(yr<100 ds yy \n(yr el \{ \" else, subtract 100 from yr, store in ny nr ny \n(yr-100

.ie \n(ny>9 \{ \" use ny if it is two digits ds yy \n(ny

.\" remove temporary number register ny rr ny \}

.el \{.ds yy 0 \" if ny is one digit, append it to 0 as yy \n(ny

.rr ny \} \}

troff(1)

Trang 18

true, false – provide truth values

true false

truedoes nothing, successfully false does nothing, unsuccessfully They aretypically used in a shell script sh as:

while true do

command done

which executes command forever

truehas exit status 0

falsealways will exit with a non-zero value

See attributes(5) for descriptions of the following attributes:

Trang 19

truss – trace system calls and signals

truss [-fcaeildD] [- [tTvx] [!] syscall ,…] [sS] [!] signal ,…]

[-[mM] [!] fault ,…] [- [rw] [!] fd ,…] [- [uU] [!] lib ,… : [:] [!] func ,…] [-o outfile]command | -p pid…

The truss utility executes the specified command and produces a trace of the systemcalls it performs, the signals it receives, and the machine faults it incurs Each line ofthe trace output reports either the fault or signal name or the system call name with itsarguments and return value(s) System call arguments are displayed symbolicallywhen possible using defines from relevant system headers; for any path name pointerargument, the pointed-to string is displayed Error returns are reported using the errorcode names described in intro(3)

Optionally (see the -u option), truss will also produce an entry/exit trace ofuser-level function calls executed by the traced process, indented to indicate nesting.The following options are recognized For those options that take a list argument, thename all can be used as a shorthand to specify all possible members of the list If thelist begins with a !, the meaning of the option is negated (for example, exclude ratherthan trace) Multiple occurrences of the same option may be specified For the samename in a list, subsequent options (those to the right) override previous ones (those tothe left)

-p

Interprets the command arguments to truss as a list of process-ids for existing

processes (see ps(1)) rather than as a command to be executed truss takes control

of each process and begins tracing it provided that the userid and groupid of theprocess match those of the user or that the user is a privileged user Processes mayalso be specified by their names in the /proc directory, for example,

/proc/12345.-f

Follows all children created by fork() or vfork() and includes their signals,faults, and system calls in the trace output Normally, only the first-level command

or process is traced When -f is specified, the process-id is included with each line

of trace output to indicate which process executed the system call or received thesignal

-cCounts traced system calls, faults, and signals rather than displaying the traceline-by-line A summary report is produced after the traced command terminates orwhen truss is interrupted If -f is also specified, the counts include all tracedsystem calls, faults, and signals for child processes

-aShows the argument strings that are passed in each exec() system call

-eShows the environment strings that are passed in each exec() system call

Trang 20

Do not display interruptible sleeping system calls Certain system calls, such asopen()and read() on terminal devices or pipes, can sleep for indefinite periodsand are interruptible Normally, truss reports such sleeping system calls if theyremain asleep for more than one second The system call is reported again a secondtime when it completes The -i option causes such system calls to be reported onlyonce, when they complete

-l

Includes the id of the responsible lightweight process (LWP) with each line of trace

output If -f is also specified, both the process-id and the LWP-id are included.-d

Includes a time stamp on each line of trace output The time stamp appears as a

field containing seconds fraction at the start of the line This represents a time in

seconds relative to the beginning of the trace The first line of the trace output willshow the base time from which the individual time stamps are measured, both asseconds since the epoch (see time(2)) and as a date string (see ctime(3C) anddate(1)) The times that are reported are the times that the event in questionoccurred For all system calls, the event is the completion of the system call, not thestart of the system call

-D

Includes a time delta on each line of trace output The value appears as a field

containing seconds fraction and represents the elapsed time for the LWP that

incurred the event since the last reported event incurred by that LWP Specifically,for system calls, this is not the time spent within the system call

-t[!]syscall,

System calls to trace or exclude Those system calls specified in the

comma-separated list are traced If the list begins with a !, the specified systemcalls are excluded from the trace output Default is -tall

-T[!]syscall,

System calls that stop the process The specified system calls are added to the setspecified by -t If one of the specified system calls is encountered, truss leavesthe process stopped and abandoned That is, truss releases the process and exitsbut leaves the process in the stopped state at completion of the system call inquestion A debugger or other process inspection tool (see proc(1)) can then beapplied to the stopped process truss can be reapplied to the stopped process withthe same or different options to continue tracing Default is -T!all

A process left stopped in this manner cannot be restarted by the application ofkill -CONTbecause it is stopped on an event of interest via /proc, not by thedefault action of a stopping signal (see signal(3HEAD)) The prun(1) commanddescribed in proc(1) can be used to set the stopped process running again

-v[!]syscall,

Verbose Displays the contents of any structures passed by address to the specifiedsystem calls (if traced by -t) Input values as well as values returned by the

truss(1)

Trang 21

operating system are shown For any field used as both input and output, only theoutput value is shown Default is -v!all.

-x[!]syscall,

Displays the arguments to the specified system calls (if traced by -t) in raw form,usually hexadecimal, rather than symbolically This is for unredeemed hackers whomust see the raw bits to be happy Default is -x!all

-s[!]signal,

Signals to trace or exclude Those signals specified in the comma-separated list aretraced The trace output reports the receipt of each specified signal, even if thesignal is being ignored (not blocked) (Blocked signals are not received until theyare unblocked.) Signals may be specified by name or number (see

<sys/signal.h>) If the list begins with a !, the specified signals are excludedfrom the trace output Default is -sall

-S[!]signal,

Signals that stop the process The specified signals are added to the set specified by-s If one of the specified signals is received, truss leaves the process stopped andabandoned (see the -T option) Default is -S!all

-r[!]fd,

Shows the full contents of the I/O buffer for each read() on any of the specifiedfile descriptors The output is formatted 32 bytes per line and shows each byte as anASCII character (preceded by one blank) or as a 2-character C language escapesequence for control characters such as horizontal tab ( \ t) and newline ( \ n) IfASCII interpretation is not possible, the byte is shown in 2-character hexadecimalrepresentation (The first 12 bytes of the I/O buffer for each traced read() areshown even in the absence of -r.) Default is -r!all

-w[!]fd,

Shows the contents of the I/O buffer for each write() on any of the specified filedescriptors (see the -r option) Default is -w!all

-u[!]lib, :[:][!]func, User-level function call tracing lib, is a comma-separated list of dynamic library names, excluding the ‘‘.so.n’’ suffix func, is a comma-separated list of function

names In both cases the names can include name-matching metacharacters *,?,[]with the same meanings as those of sh(1) but as applied to the library/functionname spaces, not to files An empty library or function list defaults to *, trace alllibraries or functions in a library A leading ! on either list specifies an exclusiontruss(1)

Trang 22

list, names of libraries or functions not to be traced Excluding a library excludes allfunctions in that library; any function list following a library exclusion list isignored.

A single : separating the library list from the function list means to trace calls intothe libraries from outside the libraries, but omit calls made to functions in a libraryfrom other functions in the same library A double : : means to trace all calls,regardless of origin

Library patterns do not match either the executable file or the dynamic linkerunless there is an exact match (l* will not match ld.so.1) To trace functions ineither of these objects, the names must be specified exactly, as in: truss -u a.out-u ld a.out is the literal name to be used for this purpose; it does not standfor the name of the executable file Tracing a.out function calls implies all calls(default is : :)

Multiple -u options may be specified and they are honored left-to-right If theprocess is linked with -lthread, the id of the thread that performed the functioncall is included in the trace output for the call truss searches the dynamic symboltable in each library to find function names and will also search the standardsymbol table if it has not been stripped

-U[!]lib, :[:][!]func,

User-level function calls that stop the process The specified functions are added tothe set specified by -u If one of the specified functions is called, truss leaves theprocess stopped and abandoned (see the -T option)

-ooutfile

File to be used for the trace output By default, the output goes to standard error

See man pages section 2: System Calls for system call names accepted by the -t, -T, -v,

and -x options System call numbers are also accepted

If truss is used to initiate and trace a specified command and if the -o option is used

or if standard error is redirected to a non-terminal file, then truss runs with hangup,interrupt, and quit signals ignored This facilitates tracing of interactive programs thatcatch interrupt and quit signals from the terminal

If the trace output remains directed to the terminal, or if existing processes are traced(the -p option), then truss responds to hangup, interrupt, and quit signals by

releasing all traced processes and exiting This enables the user to terminate excessivetrace output and to release previously-existing processes Released processes continuenormally, as though they had never been touched

EXAMPLE 1Tracing a command

This example produces a trace of the find(1) command on the terminal:

example$ truss find -print >find.out

truss(1)

EXAMPLES

Trang 23

EXAMPLE 1Tracing a command (Continued)

EXAMPLE 2Tracing common system calls

To see only a trace of the open, close, read, and write system calls:

example$ truss -t open,close,read,write find -print >find.out

EXAMPLE 3Tracing a shell script

This produces a trace of the spell(1) command on the file truss.out:

example$ truss -f -o truss.out spell document

spellis a shell script, so the -f flag is needed to trace not only the shell but also theprocesses created by the shell (The spell script runs a pipeline of eight processes.)

EXAMPLE 4Abbreviating output

A particularly boring example is:

example$ truss nroff -mm document >nroff.out

because 97% of the output reports lseek(), read(), and write() system calls Toabbreviate it:

example$ truss -t ! lseek,read,write nroff -mm document >nroff.out

EXAMPLE 5Tracing library calls from outside the C library

This example traces all user-level calls made to any function in the C library fromoutside the C library:

example$ truss -u libc

EXAMPLE 6Tracing library calls from within the C library

This example includes calls made to functions in the C library from within the Clibrary itself:

example$ truss -u libc : :

EXAMPLE 7Tracing library calls other than the C library

This example traces all user-level calls made to any library other than the C library:

example$ truss -u ’*’ -u !libc

EXAMPLE 8Tracing printf and scanf function calls

This example traces all user-level calls to functions in the printf and scanf familycontained in the C library:

truss(1)

Trang 24

EXAMPLE 8Tracing printf and scanf function calls (Continued)

example$ truss -u ’libc : *printf,*scanf’

EXAMPLE 9Tracing any user-level function call

This example traces every user-level function call from anywhere to anywhere:

example$ truss -u a.out -u ld : : -u : :

EXAMPLE 10Tracing a system call verbosely

This example verbosely traces the system call activity of process #1, init(1M) (if youare a privileged user):

example# truss -p -v all 1

Interrupting truss returns init to normal operation

/proc/* process filesSee attributes(5) for descriptions of the following attributes:

SUNWtoox (64-bit)

date(1), find(1), proc(1), ps(1), sh(1), spell(1), init (1M), intro(3), exec(2),fork(2), lseek(2), open(2), read(2), time(2), vfork(2), write(2), ctime(3C),threads(3THR), proc(4), attributes(5), signal(3HEAD)

man pages section 2: System Calls Some of the system calls described in man pages section 2: System Calls differ from the

actual operating system interfaces Do not be surprised by minor deviations of thetrace output from the descriptions in that document

Every machine fault (except a page fault) results in the posting of a signal to the LWPthat incurred the fault A report of a received signal will immediately follow eachreport of a machine fault (except a page fault) unless that signal is being blocked.The operating system enforces certain security restrictions on the tracing of processes

In particular, any command whose object file (a.out) cannot be read by a user cannot

be traced by that user; set-uid and set-gid commands can be traced only by aprivileged user Unless it is run by a privileged user, truss loses control of anyprocess that performs an exec() of a set-id or unreadable object file; such processescontinue normally, though independently of truss, from the point of the exec()

Trang 25

To avoid collisions with other controlling processes, truss will not trace a processthat it detects is being controlled by another process via the /proc interface Thisallows truss to be applied to proc(4)-based debuggers as well as to another instance

Not all possible structures passed in all possible system calls are displayed under the-voption

truss(1)

Trang 26

tset, reset – establish or restore terminal characteristics

tset [-InQrs] [-ec] [-kc] [-m [port-ID [baudrate] : type…]] [type]

reset [-] [-ec] [-I] [-kc] [-n] [-Q] [-r] [-s] [-m [indent] [test baudrate] : type…] [type]

The tset utility sets up your terminal, typically when you first log in It does terminaldependent processing such as setting erase and kill characters, setting or resettingdelays, sending any sequences needed to properly initialized the terminal, and thelike tset first determines the type of terminal involved, and then does necessaryinitializations and mode settings If a port is not wired permanently to a specificterminal (not hardwired) it is given an appropriate generic identifier such as dialup.resetclears the terminal settings by turning off CBREAK and RAW modes, outputdelays and parity checking, turns on NEWLINE translation, echo and TAB expansion,and restores undefined special characters to their default state It then sets the modes

as usual, based on the terminal type (which will probably override some of the above).See stty(1) for more information All arguments to tset may be used with reset.resetalso uses rs= and rf= to reset the initialization string and file This is usefulafter a program dies and leaves the terminal in a funny state Often in this situation,characters will not echo as you type them You may have to type LINEFEED resetLINEFEED since RETURN may not work

When no arguments are specified, tset reads the terminal type from the TERMenvironment variable and re-initializes the terminal, and performs initialization ofmode, environment and other options at login time to determine the terminal type andset up terminal modes

When used in a startup script (.profile for sh(1) users or login for csh(1) users)

it is desirable to give information about the type of terminal you will usually use onports that are not hardwired Any of the alternate generic names given in the file/etc/termcapare possible identifiers Refer to the -m option below for moreinformation If no mapping applies and a final type option, not preceded by a -m, isgiven on the command line then that type is used

It is usually desirable to return the terminal type, as finally determined by tset, andinformation about the terminal’s capabilities, to a shell’s environment This can bedone using the−, -s, or -S options

For the Bourne shell, put this command in your profile file:

eval ‘tset -s options ‘

or using the C shell, put these commands in your login file:

set noglob eval ‘tset -s options ‘unset noglob

With the C shell, it is also convenient to make an alias in your cshrc file:

alias ts ’eval ‘tset -s \!*‘’

tset(1B)

NAME

SYNOPSIS

DESCRIPTION

Trang 27

This also allows the command:

ts 2621

to be invoked at any time to set the terminal and environment It is not possible to getthis aliasing effect with a Bourne shell script, because shell scripts cannot set theenvironment of their parent If a process could set its parent’s environment, none ofthis nonsense would be necessary in the first place

Once the terminal type is known, tset sets the terminal driver mode This normallyinvolves sending an initialization sequence to the terminal, setting the single charactererase (and optionally the line-kill (full line erase)) characters, and setting specialcharacter delays TAB and NEWLINE expansion are turned off during transmission ofthe terminal initialization sequence

On terminals that can backspace but not overstrike (such as a CRT), and when theerase character is ‘#’, the erase character is changed as if -e had been used

− The name of the terminal finally decided upon is output on the

standard output This is intended to be captured by the shell andplaced in the TERM environment variable

-ec Set the erase character to be the named character c on all terminals.

Default is the BACKSPACE key on the keyboard, usually ^H

(CTRL-H) The character c can either be typed directly, or entered

using the circumflex-character notation used here

-ic Set the interrupt character to be the named character c on all

terminals Default is ^C (CTRL-C) The character c can either be

typed directly, or entered using the circumflex-character notationused here

-I Suppress transmitting terminal-initialization strings

-kc Set the line kill character to be the named character c on all

terminals Default is ^U (CTRL-U) The kill character is left alone if-kis not specified Control characters can be specified by prefixingthe alphabetical character with a circumflex (as in CTRL-U) instead

of entering the actual control key itself This allows you to specifycontrol keys that are currently assigned

-n Specify that the new tty driver modes should be initialized for this

terminal Probably useless since stty new is the default

-Q Suppress printing the ‘Erase set to’ and ‘Kill set to’

messages

-r In addition to other actions, reports the terminal type

-s Output commands to set and export TERM This can be used with

set noglob eval ‘tset -s ‘

unset noglob

tset(1B)

OPTIONS

Trang 28

to bring the terminal information into the environment Doing somakes programs such as vi(1) start up faster If the SHELLenvironment variable ends with csh, C shell commands areoutput, otherwise Bourne shell commands are output.

-m[ port-ID [ baudrate ] : type ]

Specify (map) a terminal type when connected to a generic port (such as dialup or plugboard) identified by port-ID The baudrate argument can be used to check the

baudrate of the port and set the terminal type accordingly The target rate isprefixed by any combination of the following operators to specify the conditionsunder which the mapping is made:

> Greater than

@ Equals or ‘‘at’’

< Less than

! It is not the case that (negates the above operators)

? Prompt for the terminal type If no response is given, then type is

selected by default

In the following example, the terminal type is set to adm3a if the port is a dialup with

a speed of greater than 300 or to dw2 if the port is a dialup at 300 baud or less In thethird case, the question mark preceding the terminal type indicates that the user is toverify the type desired A NULL response indicates that the named type is correct.Otherwise, the user’s response is taken to be the type desired

tset -m ’dialup>300:adm3a’ -m ’dialup:dw2’ -m ’plugboard:?adm3a’

To prevent interpretation as metacharacters, the entire argument to -m should beenclosed in single quotes When using the C shell, exclamation points should bepreceded by a backslash (\)

These examples all use the ‘−’ option A typical use of tset in a profile or loginwill also use the -e and -k options, and often the -n or -Q options as well Theseoptions have been omitted here to keep the examples short

EXAMPLE 1Selecting a terminal

To select a 2621, you might put the following sequence of commands in your loginfile (or profile for Bourne shell users)

Trang 29

EXAMPLE 1Selecting a terminal (Continued)

EXAMPLE 2Selecting terminals according to speed or baud rate

If you have a switch which connects to various ports (making it impractical to identifywhich port you may be connected to), and use various terminals from time to time,

you can select from among those terminals according to the speed or baud rate In the

example below, tset will prompt you for a terminal type if the baud rate is greaterthan 1200 (say, 9600 for a terminal connected by an RS-232 line), and use a Wyse® 50

by default If the baud rate is less than or equal to 1200, it will select a 2621 Note theplacement of the question mark, and the quotes to protect the > and ? from

interpretation by the shell

set noglob eval ‘tset -s -m ’switch>1200:?wy’ -m ’switch<=1200:2621’‘

unset noglob

EXAMPLE 3Selecting the terminal used most often

The following entry is appropriate if you always dial up, always at the same baudrate, on many different kinds of terminals, and the terminal you use most often is anadm3a

set noglob eval ‘tset -s ?adm3a‘

unset noglob

EXAMPLE 4Selecting a terminal with specific settings

The following example quietly sets the erase character to BACKSPACE, and kill toCTRL-U If the port is switched, it selects a Concept™ 100 for speeds less than or equal

to 1200, and asks for the terminal type otherwise (the default in this case is a Wyse 50)

If the port is a direct dialup, it selects Concept 100 as the terminal type If logging inover the ARPANET, the terminal type selected is a Datamedia® 2500 terminal oremulator Note the backslash escaping the NEWLINE at the end of the first line in theexample

set noglob eval ‘tset -e -k^U -Q -s -m ’switch<=1200:concept100’ -m\

’switch:?wy’ -m dialup:concept100 -m arpanet:dm2500‘

unset noglob

tset(1B)

Trang 30

EXAMPLE 4Selecting a terminal with specific settings (Continued)

.login.profile/etc/termcapSee attributes(5) for descriptions of the following attributes:

csh(1), sh(1), stty(1), vi(1), attributes(5), environ(5)The tset command is one of the first commands a user must master when gettingstarted on a UNIX system Unfortunately, it is one of the most complex, largelybecause of the extra effort the user must go through to get the environment of thelogin shell set Something needs to be done to make all this simpler, either the loginprogram should do this stuff, or a default shell alias should be made, or a way to setthe environment of the parent should exist

This program cannot intuit personal choices for erase, interrupt and line killcharacters, so it leaves these set to the local system standards

It could well be argued that the shell should be responsible for ensuring that theterminal remains in a sane state; this would eliminate the need for the resetprogram

Trang 31

tsort – topological sort

The following operand is supported:

file A path name of a text file to order If no file operand is given, the

standard input is used

EXAMPLE 1An example of the tsort command

produces the output:

a b c d e f g

See environ(5) for descriptions of the following environment variables that affect theexecution of tsort: LC_CTYPE, LC_MESSAGES, and NLSPATH

The following exit values are returned:

0 Successful completion

>0 An error occurred

See attributes(5) for descriptions of the following attributes:

Trang 32

Odd data:there are an odd number of fields in the input file.

tsort(1)

DIAGNOSTICS

Trang 33

tty – return user’s terminal name

tty [-l] [-s]

The tty utility writes to the standard output the name of the terminal that is open asstandard input The name that is used is equivalent to the string that would bereturned by the ttyname(3C) function

The following options are supported:

-l Prints the synchronous line number to which the user’s terminal is

connected, if it is on an active synchronous line

-s Inhibits printing of the terminal path name, allowing one to test just the

exit status

See environ(5) for descriptions of the following environment variables that affect theexecution of tty: LC_CTYPE, LC_MESSAGES, and NLSPATH

The following exit values are returned:

0 Standard input is a terminal

1 Standard input is not a terminal

>1 An error occurred

See attributes(5) for descriptions of the following attributes:

The -s option is useful only if the exit status is wanted It does not rely on the ability

to form a valid path name Portable applications should use test -t

Trang 34

type – write a description of command type

type name…

The type utility indicates how each name operand would be interpreted if used as a

command type displays information about each operand identifying the operand as

a shell built-in, function, alias, hashed command, or keyword, and where applicable,may display the operand’s path name

There is also a shell built-in version of type that is similar to the type utility

The following operand is supported:

name A name to be interpreted

See environ(5) for descriptions of the following environment variables that affect theexecution of type: LC_CTYPE, LC_MESSAGES, and NLSPATH

PATH Determine the location of name.

The following exit values are returned:

0 Successful completion

>0 An error occurred

See attributes(5) for descriptions of the following attributes:

Trang 35

typeset, whence – shell built-in functions to set/get attributes and values for shellvariables and functions

typeset [± HLRZfilrtux [n]] [name [= value]]…

whence [-pv] name…

typesetsets attributes and values for shell variables and functions When typeset

is invoked inside a function, a new instance of the variables name is created The variables value and type are restored when the function completes The following list

of attributes may be specified:

-H This flag provides UNIX to host-name file mapping on non-UNIX

machines

-L Left justify and remove leading blanks from value If n is non-zero it defines

the width of the field; otherwise, it is determined by the width of the value

of first assignment When the variable is assigned to, it is filled on the rightwith blanks or truncated, if necessary, to fit into the field Leading zeros areremoved if the -Z flag is also set The -R flag is turned off

-R Right justify and fill with leading blanks If n is non-zero it defines the

width of the field, otherwise it is determined by the width of the value offirst assignment The field is left filled with blanks or truncated from theend if the variable is reassigned The -L flag is turned off

-Z Right justify and fill with leading zeros if the first non-blank character is a

digit and the -L flag has not been set If n is non-zero it defines the width

of the field; otherwise, it is determined by the width of the value of firstassignment

-f The names refer to function names rather than variable names No

assignments can be made and the only other valid flags are -t, -u and -x.The flag -t turns on execution tracing for this function The flag -u causesthis function to be marked undefined The FPATH variable will be searched

to find the function definition when the function is referenced The flag -xallows the function definition to remain in effect across shell proceduresinvoked by name

-i Parameter is an integer This makes arithmetic faster If n is non-zero it

defines the output arithmetic base; otherwise, the first assignmentdetermines the output base

-l All upper-case characters are converted to lower-case The upper-case flag,

-uis turned off

-r The given names are marked readonly and these names cannot be

changed by subsequent assignment

-t Tags the variables Tags are user definable and have no special meaning to

Trang 36

-u All lower-case characters are converted to upper-case characters The

lower-case flag, -l is turned off

-x The given names are marked for automatic export to the environment of

subsequently-executed commands

The -i attribute can not be specified along with -R, -L, -Z, or -f

Using + rather than− causes these flags to be turned off If no name arguments are given but flags are specified, a list of names (and optionally the values) of the variables

which have these flags set is printed (Using + rather than− keeps the values from

being printed.) If no names and flags are given, the names and attributes of all variables

are printed

For each name, whence indicates how it would be interpreted if used as a command

name

The -v flag produces a more verbose report

The -p flag does a path search for name even if name is an alias, a function, or a

2 I/O redirections are processed after variable assignments

3 Errors cause a script that contains them to abort

4 Words, following a command preceded by ** that are in the format of a variableassignment, are expanded with the same rules as a variable assignment Thismeans that tilde substitution is performed after the = sign and word splitting andfile name generation are not performed

See attributes(5) for descriptions of the following attributes:

Ngày đăng: 24/07/2014, 02:20

TỪ KHÓA LIÊN QUAN