1. Trang chủ
  2. » Công Nghệ Thông Tin

Sun Fundamentals of Solaris 7 Student Guide With Instructor Notes phần 10 ppt

75 309 0

Đ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 đề A History in the C Shell Command-Line Substitution
Trường học Sun Microsystems, Inc.
Chuyên ngành Fundamentals of Solaris 7
Thể loại hướng dẫn
Năm xuất bản 1999
Thành phố Enterprise Services
Định dạng
Số trang 75
Dung lượng 290,86 KB

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

Nội dung

This appendix provides the following information for accessing mailfrom the command line:● Sending mail from the command line using the mailxprogram ● Reading and printing messages ● Cre

Trang 1

History in the C Shell

Command-Line Substitution

Use!!to execute the most recent command exactly as it was executedpreviously If you enteredlpstat, sent some print jobs from otherterminal windows, and want to enter thelpstatcommand againfrom the original terminal window, type!!at the shell prompt toexecutelpstatthe second time For example:

Use!*to repeat all arguments of the previous command

Use!$to repeat the last argument of the previous command Forexample:

% cd

% mkdir a b c

% ls !*

ls a b ca:

Trang 2

History in the C Shell

Command-Line Substitution

% ls -l > /tmp/list.file

% more !$

more /tmp/list.filetotal 90

-rw-r r 1 user2 other 72 Jun 21 15:07 dante-rw-r r 1 user2 other 72 Jun 21 15:07 dante_1drw-r r 5 user2 other 512 Sep 28 16:39 dir1

drw-r r 2 user2 other 512 Sep 29 09:45 lettersdrw-r r 4 user2 other 512 Sep 29 10:01 practice

%

Trang 3

C Shell Features

Customizing Your Prompt

The C shell enables customization of your system prompt

Command Format

set prompt=value

Changing Your Prompt

% set prompt="What’s Next? "

What’s Next? set prompt="Hello, ‘hostname‘ "

Hello, venus set prompt="% "

%

When you change your current command prompt to something new,the new prompt will remain until you change it again or until you logout

To make your change permanent, add theset promptcommand tothe.cshrcfile for the C shell

Trang 4

C Shell Features

Aliases

Command aliases are available in the Korn and C shells, but they arenot available in the Bourne shell

A command alias enables you to

● Substitute a short command for a long one

● Create a single command for a series of commands

● Create alternate forms of existing commands

● Change a command set

Trang 6

This appendix provides the following information for accessing mailfrom the command line:

● Sending mail from the command line using the mailxprogram

● Reading and printing messages

● Creating and using a mail alias

Trang 7

Introduction to mailx

The Solaris operating environment provides a program calledmailx

for sending and receiving electronic mail (email) Themailxprogramprovides facilities for reading, writing, sending, receiving, saving, anddeleting messages from the command line

Themailxprogram (utility) is not window-based; therefore, it can berun in either a window environment or from any terminal

Trang 8

Command-Line Mail

Use the mailxprogram from the command-line when:

● You are using a command-line login shell

● You are using a terminal

● You remotely log in to your workstation to read your mail

Command Format

mailxmailx username@hostname

Each user has a mailboxfile in which to receive mail By default, thismailbox is located in/var/mail/username, whereusernameis yourlogin ID

Themailxprogram notifies you when you receive mail and places themail in your mailbox After you have read your mail, mailx

automatically places these letters in a storage file calledmbox, which islocated in your home directory

Reading Your Mail

Trang 9

Sending a Mail Message

To send mail:

1 Specifyusername@hostnameas an argument to the mailx

command

2 Enter the subject of your mail and press Return

3 Enter the text of your message, and press the (period) key orControl-d (to transmit message) on a line by itself to signal the end

of the message

For example:

$ mailx user3@saturn Subject: lunch!

Hi there!

Do you have any plans for lunch today?

If not, would you care to join me?

user2 (Type a dot [.] and press Return)

EOT

$

(EOT is an acronym for end of transmission.)

Trang 10

Canceling a Mail Message

Press Control-c to cancel a mail message

$ mailx user3@saturn Subject: lunch!

Do you have any plans (press Control-c)

^C(Interrupt one more to kill letter)

(press Control-c)

^C “/home/user2/dead.letter” 3/29

$

Note – Each line of text within your letter can be up to 256 characters

long When you exceed this limitation, your screen will freeze If thisoccurs, press Control-c to abort your letter

If you cancel a message, it is saved in your home directory under thename dead.letter Either remove this file or save the text underanother name for later transmission

Trang 11

Reading a Mail Message

If you have mail,mailxnotifies you each time you log in with themessage:

You have mail.or

You have new mail

To read your mail messages, invoke themailxprogram

$ mailx

mailx version 5.0 Thu Aug 5 10:36:57 PDT 1999 type ? forhelp

“/var/mail/user2”: 2 messages 2 new

>N1 user3Mon May 14 14:4416/334About lunch!

N2 user4Mon May 14 14:5314/326Your lunch

?

Note – The question mark (?) is the mail prompt.

When you have a large number of letters in your mailbox, thedisplayed list may not show all of your mail headers If this is the case,type one of the following options:

h Redisplays the list of mail

headers at any time

Trang 12

Reading a Mail Message

The output from themailxcommand is called themail header Themail header displays:

● The version of the program

● A question mark (?) for help with mail

● The location of the mail box (for example,/var/mail/username)where your mail messages are saved

● The status of the mail box:

▼ The total number of messages in the mail box

▼ The number of new messages

▼ The status (new or unread) for each message

▼ The number of each message in the order it was received

▼ The sender (user and machine name)

▼ The time and date the message was sent

▼ The size of the message (the number of lines and number ofcharacters in the message)

▼ The subject of the message

Mail Headers

$ mailx

mailx version 5.0 Thu Aug 5 10:36:57 PDT 1999 type ?for help

“/var/mail/user2”: 2 messages 2 new

>N 1 user3 Mon May 14 14:4416/334 About lunch!

N 2 user4 Mon May 14 14:5314/326 Your lunch

?

Trang 13

Reading a Mail Message

When a new message is received, or an old message was not read, one

of the following characters appears next to the applicable message:

To read the first mail message, press Return at the mail prompt (?).The first (or current) message appears on your screen

Press Return to read any subsequent messages

If you want to select a specific mail message to read, type the number

of the mail message at the mail prompt and press Return

Table B-1 Message Classification Characters Character Message

N Indicates a new message

U Indicates a message that was received

earlier, but was not read beforequitting themailx programpreviously

R Indicates a new message that was read

during the current invocation of

mailx

O Indicates a message that was read

previously and is saved in the currentmail box

> Indicates current message

? Indicates which message number, or if

typed by user, listing of options tolook for

Trang 14

Reading a Mail Message

Reading a Specific Message

$ mailx

mailx version 5.0 Thu Aug 5 10:36:57 PDT 1999 Type?for help

"/var/mail/user2": 2 messages 2 new

>N 1 user3 Mon May 14 14:4416/334About lunch!

N 2 user4 Mon May 14 14:5314/326Your lunch

Hi user2!

I heard you are going out to lunch

Mind if I join you?

user4

?

Trang 15

Deleting and Undeleting a Mail Message

Use thed(delete) command withinmailxto delete mail messages

Trang 16

Replying to a Mail Message

Use the rcommand withinmailxto reply to the current message Forexample:

$ mailx

mailx version 5.0 Thu Aug 5 10:36:57 PDT 1999 Type? for help

"/var/mail/user2": 2 messages 2 new

>N 1 user3 Mon Aug 2 14:44 16/334 About lunch!

N 2 user4 Mon Aug 2 14:53 14/326 Your lunch

I have no plans for lunch and would be happy

to join you

user3

? r

To: user3@saturnSubject: Re: About lunch!

Great! Let’s meet in the lobby after class.

user2

.EOT

?

Trang 17

Replying to a Mail Message

To reply to a non-current message, type:

? rnumber

Your reply will be sent to the sender of the message

To reply to the sender and everyone who received the currentmessage, type:

? R

To reply to the sender and everyone who received a non-currentmessage, type:

? R number

Note – Be careful about using R to reply if you are sending any

confidential information Mail messages are frequently sent to largegroups of people that you may not want receiving the contents of yourreply

Trang 18

Saving a Mail Message

To save a current message, type:

? s filename

This will save the message in the specified file in your home directory

A saved message can be read using the cator morecommands, oredited using vi, the CDE Text Editor, or any editor your system uses

To save a non-current message, type:

? s <message number> filename

Trang 19

Printing a Mail Message

Use thelpcommand with the pipe (|) symbol to print a mail messagewithinmailx

I have no plans for lunch, and would be happy

The mail message is printed to your default printer

You can specify a destination printer by using thelp -d printernameoption.

Trang 20

Quitting Mail

Use the q(quit) command to save changes and exit mailx Read andunread messages are automatically stored

If you exit using q, unread messages remain in

/var/mail/username By default, read messages are stored in the

mboxfile in your home directory

It is good practice to save messages that contain important information

in a separate file and to clean out yourmboxon a regular basis as it cangrow quite large

Use the xcommand to exitmailxwithout saving changes

To access messages stored in your mboxfile, type:

$ mailx -f

mailx version 5.0 Thu Aug 5 10:36:57 PDT 1999 Type? for help

"/export/home/user2/mbox": 5 messages

>0 1 user1 Mon Aug 14 09:08 15/342 News

0 2 user5 Mon Aug 14 10:25 90/555 Meeting

0 3 user3 Mon Aug 14 10:52 33/912 Project

0 4 user1 Mon Aug 14 11:58 45/215 Deadline

0 5 user4 Mon Aug 14 12:02 16/347 Interview

0 6 user3 Mon Aug 14 14:45 16/334 About lunch!

0 7 user4 Mon Aug 14 14:53 14/326 Your lunch

?

Trang 21

Sending a File Using Mail

Use themailxcommand and standard input redirection to sendsomeone a file For example:

$ mailx user3@saturn < dante

Note – When writing mail messages, remember to press Return at the

end of each line There is no automatic line wrap with mail

Note – A piece of email is not a single file A piece of email is made into pages, which are appended into one file By default, the storage area for all mail messages is

/var/mail/username.

Trang 22

Creating a Mail Alias

A mail alias is a group of user names (login IDs) in a single file Use

mail aliases when you want to send the same message to a group of

users A mail alias is also called a distribution list.

Command Format

mailx aliasname

Use an editor to add mail aliases to your.mailrcfile, which is located

in your home (or login) directory The.mailrcfile is used to store

private mail aliases and variables relating to the mail program Your

system administrator can set up public mail aliases, available for anyuser on the system to use, in the /etc/aliasesfile

You can use any editor to create or add mail aliases to the.mailrcfile.Create one mail alias per line, and then save the changes For example:

This is a test of my newly created alias

user2

EOT

Trang 23

Using Tilde Commands

While composing a letter, you can use tilde commands to perform avariety of functions

Command Format

~single character [string]

Table B-2 lists some of the more useful tilde commands

Note – If you want to include a literal tilde character in a letter, type

two tildes in succession Only one tilde will be displayed

Table B-2 Tilde Commands and Functions

Command Function

~!command Escapes to a shell command

~ Simulates pressing Control-d to mark end of file

~? Lists a summary of tilde commands

~b username Adds user name(s) to the blind carbon copies (Bcc:) list

~c username Adds user name(s) to the carbon copies (Cc:) list

~f number Forwards the specified letter; valid only when sending a message

while reading mail

~h Prompts for header lines: Subject, To, Cc, and Bcc

~r filename Reads in the text from the specified file

~t name Adds the specified name(s) to the To list

~p Prints the message being entered to the screen

~s string Changes the subject line to string

~t name Adds the specified name(s) to the To list

~m number Inserts text from the specified letter into the current letter; valid

only when sending a message while reading mail

Trang 24

Using Tilde Commands

The following example demonstrates the use of some of the tildecommands to make a change to the Subject line (~sstring) and torefresh and print the message being entered to the screen (~p):

$ mailx all_staff_alias

Subject: Meeting Today There will be a staff meeting at 3:00 p.m today

~s Staff meeting 3:00 p.m Today

in the large conference room.

Please be prompt.

~p

Message contains:

-To: all_staff_aliasSubject: Staff Meeting 3:00 p.m Today

There will be a staff meeting at 3:00 p.m today

in the large conference room

Please be prompt

(continue)

.

EOT

Trang 26

This appendix provides suggested solutions for the Workshop Labspresented in the text These solutions are only one way to solve eachproblem Many of the scenarios have multiple solutions and no onesolution is the correct answer.

Trang 27

Module 1 – Solaris Computing Environment

1 Because the user had not saved the work done before the poweroutage, it was still in RAM memory Both RAM and swap arecleaned out on reboot Thus, the work was lost

2 The user could save work to another workstation’s disk, to tape, or

to diskette

Trang 28

Module 2 – Accessing Your System

1 The employee may not have been able to log in to the systembecause he or she forgot or mistyped the password, the systemadministrator changed the password for various reasons, the login

ID was incorrect, or he or she does not have an active account yet

2 The system administrator must set the user up to log in to aspecific shell environment This information is kept in the

/etc/passwdfile

Trang 29

Module 3 – Introduction to the Common Desktop Environment

1

a Change names of workstation buttons

b Use Style Manager

c Use option in Style Manager

d Use exit option in Style Manager

2 Drop icon from Application Manager, Desktop_Apps windowonto Install Icon part of subpanel Use Promote to Front Panelmenu option to put icon on the Front Panel

3 Putting your mouse pointer in a blank space on the Front Panel,click on Add Icon Then drop Calculator icon from the ApplicationManager, Desktop_Apps window on the new space in the FrontPanel

Trang 30

Module 4 – Getting Help

1 Use Front Panel Help to get information on Calendar Manager Ifdifficulties arise with specifics after using the general help, useapplication-specific help by clicking on the Help menu in theupper right corner of the Calendar Manager window

2 Look at the manpage for the/etc/passwdfile by using:

$ man -s 4 passwd

Trang 31

Module 5 – Accessing Files and Directories

1 Look at the man page for an option to thelscommand that willdisplay directory listings with last access time rather than lastmodified time

2 You can either use:

$ ls /usr/bin/c*

or

$ man -k calendar

Trang 32

Module 6 – Directory and File Commands

1 Look in the/etc/passwdfile

2 Use themkdircommand to create the directory Then, using

Trang 33

Module 8 – File Security

Trang 34

Module 10 – Bourne and Korn Shell Variables

1.$ mkdir $HOME/dir1/coffees/flavors

Trang 35

Module 12 – Basic Features of the Korn Shell

1 $ vi kshrc

a set -o noclobber

b alias p=pwdalias l=’ls -l’

Trang 36

Module 14 – File and User Information Utilities

1 On Monday:

$ who > timely

On Tuesday through Friday:

$ who >> timely

$ sort timely | tee good.news | lp

2 $ find /etc -type d 2>/dev/null > ~/bin/file 3.$ grep -i ^[a-f] file | sort -b +1 -o file2

4 $ which cp

$ ls -i /usr/bin/cp

$ find /usr/bin -inum inode 2> /dev/null

Trang 37

Module 15 – Backing Up and Restoring

Ngày đăng: 13/08/2014, 02:23

TỪ KHÓA LIÊN QUAN