没有合适的资源?快使用搜索试试~ 我知道了~
The UNIX Programming Environment
需积分: 3 11 下载量 58 浏览量
2008-11-28
18:15:50
上传
评论
收藏 1.24MB PDF 举报
温馨提示
试读
198页
注意:The UNIX Programming Environment并不是kernighan的那本,因为那本找不到,且绝版了;但是这本与kernighan的书内容和风格很相近,可以一看
资源详情
资源评论
资源推荐
The UNIX programming environment
The UNIX programming environment
Edition 2.0, June 1997
Mark Burgess
Centre of Science and Technology
Faculty of Engineering, Oslo College
Copyright (C) 1996/7 Mark Burgess Permission is granted to make and distribute verbatim copies
of this manual provided the copyright notice and this permission notice are preserved on all
copies. Permission is granted to copy and distribute modified versions of this manual under the
conditions for verbatim copying, provided also that the section entitled "GNU General Public
License" is included exactly as in the original, and provided that the entire resulting derived work is
distributed under the terms of a permission notice identical to this one. Permission is granted to
copy and distribute translations of this manual into another language, under the above conditions
for modified versions, except that the section entitled "GNU General Public License" may be
included in a translation approved by the author instead of in the original English.
Foreword
This is a revised version of the UNIX compendium which is available in printed form and online via
the WWW and info hypertext readers. It forms the basis for a one or two semester course in UNIX.
The most up-to-date version of this manual can be found at
http://www.iu.hioslo.no/~mark/unix.html.
It is a reference guide which contains enough to help you to find what you need from other
sources. It is not (and probably can never be) a complete and self-contained work. Certain topics
are covered in more detail than others. Some topics are included for future reference and are not
intended to be part of an introductory course, but will probably be useful later. The chapter on X11
programming has been deleted for the time being.
Comments to Mark.Burgess@iu.hioslo.no Oslo, June 1996
Welcome
If you are coming to unix for the first time, from a Windows or MacIntosh environment, be
prepared for a rather different culture than the one you are used to. Unix is not about `products'
and off-the-shelf software, it is about open standards, free software and the ability to change just
about everything.
● What you personally might perceive as user friendliness in other systems, others might
file:///C|/Dokumente und Einstellungen/The UNIX programming environment.htm (1 von 198)20.11.2004 11:29:41
The UNIX programming environment
perceive as annoying time wasting. Unix offers you just about every level of friendliness and
unfriendliness, if you choose your programs right. In this book, we take the programmer's
point of view.
● Unix is about functionality, not about simplicity. Be prepared for powerful, not necessarily
`simple' solutions.
You should approach Unix the way you should approach any new system: with an open mind. The
journey begins...
Overview
In this manual the word "host" is used to refer to a single computer system -- i.e. a single machine
which has a name termed its "hostname".
What is unix?
Unix is one of the most important operating system in use today, perhaps even the most
important. Since its invention around the beginning of the 1970s it has been an object of continual
research and development. UNIX is not popular because it is the best operating system one could
imagine, but because it is an extremely flexible system which is easy to extend and modify. It is an
ideal platform for developing new ideas.
Much of the success of UNIX may be attributed to the rapid pace of its development (a
development to which all of its users have been able to contribute) its efficiency at running
programs and the many powerful tools which have been written for it over the years, such as the C
programming language, make, shell, lex and yacc and many others. UNIX was written by
programmers for programmers. It is popular in situations where a lot of computing power is
required and for database applications, where timesharing is critical. In contrast to some operating
systems, UNIX performs equally well on large scale computers (with many processors) and small
computers which fit in your suitcase!
All of the basic mechanisms required of a multi-user operating system are present in UNIX. During
the last few years it has become ever more popular and has formed the basis of newer, though
less mature, systems like NT. One reason for this that now computers have now become powerful
enough to run UNIX effectively. UNIX places burdens on the resources of a computer, since it
expects to be able to run potentially many programs simultaneously.
If you are coming to UNIX from DOS you may well be used to using applications software or
helpful interactive utilities to solve every problem. UNIX is not usually like this: the operating
system has much greater functionality and provides the possibilities for making your own, so it is
less common to find applications software which implements the same things. UNIX has long
been in the hands of academics who are used to making their own applications or writing their
own programs, whereas as the DOS world has been driven by businesses who are willing to
spend money on software. For that reason commerical UNIX software is often very expensive and
therefore not available at this college. On the other hand, the flexibility of UNIX means that it is
easy to write programs and it is possible to fetch gigabytes of free software from the internet to
suit your needs. It may not look like what you are used to on your PC, but then you have to
file:///C|/Dokumente und Einstellungen/The UNIX programming environment.htm (2 von 198)20.11.2004 11:29:41
The UNIX programming environment
remember that UNIX users are a different kind of animal altogether
Like all operating systems, UNIX has many faults. The biggest problem for any operating system
is that it evolves without being redesigned. Operating systems evolve as more and more patches
and hacks are applied to solve day-to-day problems. The result is either a mess which works
somehow (like UNIX) or a blank refusal to change (like DOS or MacIntosh). From a practical
perspective, Unix is important and successful because it is a multi-process system which
● has an enormous functionality built in, and the capacity to adapt itself to changing
technologies,
● is relatively portable,
● is good at sharing resources (but not so good at security),
● has tools which are each developed to do one thing well,
● allows these tools to be combined in every imaginable way, using pipes and channeling of
data streams,
● incorporates networking almost trivially, because all the right mechanisms are already there
for providing services and sharing, building client-server pairs etc,.
● it is very adaptable and is often used to develop new ideas because of the rich variety of
tools it possesses.
Unix has some problems: it is old, it contains a lot of rubbish which no one ever bothered to throw
away. Although it develops quickly (at light speed compared to either DOS or MacIntosh) the user
interface has been the slowest thing to change. Unix is not user-friendly for beginners, it is user-
friendly for advanced users: it is made for users who know about computing. It sometimes makes
simple things difficult, but above all it makes things possible!
The aim of this introduction is to
● introduce the unix system basics and user interface,
● develop the unix philosophy of using and combining tools,
● learn how to make new tools and write software,
● learn how to understand existing software.
To accomplish this task, we must first learn something about the shell (the way in which UNIX
starts programs). Later we shall learn how to solve more complex problems using Perl and C.
Each of these is a language which can be used to put UNIX to work. We must also learn when to
use which tool, so that we do not waste time and effort. Typical uses for these different interfaces
are
shell
Command line interaction, making scripts which perform simple jobs such as running
programs in batch, installing new software, simple system configuration and administration.
perl
Text interpretation, text formatting, output filters, mail robots, WWW cgi (common gateway
interface) scripts in forms, password testing, simple database manipulation, simple client-
server applications.
C
Nearly all of UNIX is written in C. Any program which cannot be solved quickly using shell
file:///C|/Dokumente und Einstellungen/The UNIX programming environment.htm (3 von 198)20.11.2004 11:29:41
The UNIX programming environment
or perl can be written in C. One advantage is that C is a compiled language and many
simple errors can be caught at compile time.
Much of UNIX's recent popularity has been a result of its networking abilities: unix is the backbone
of the internet. No other widely available system could keep the internet alive today.
Once you have mastered the unix interface and philosophy you will find that i) the PC and
MacIntosh window environments seem to be easy to use, but simplistic and primitive by
comparison; ii) UNIX is far from being the perfect operating system--it has a whole different set of
problems and flaws.
The operating system of the future will not be UNIX as we see it today, nor will is be DOS or
MacIntosh, but one thing is for certain: it will owe a lot to the UNIX operating system and will
contain many of the tools and mechanisms we shall describe below.
Flavours of unix
Unix is not a single operating system. It has branched out in many different directions since it was
introduced by AT&T. The most important `fork()' in its history happened early on when the
university of Berkeley, California created the BSD (Berkeley Software Distribution), adding
network support and the C-shell.
Here are some of the most common implementations of unix.
BSD:
Berkeley, BSD
SunOS:
Sun Microsystems, BSD/sys 5
Solaris:
Sun Microsystems, Sys 5/BSD
Ultrix:
Digital Equipment Corperation, BSD
OSF 1:
Digital Equipment Corperation, BSD/sys 5
HPUX:
Hewlett-Packard, Sys 5
AIX:
IBM, Sys 5 / BSD
IRIX:
Silicon Graphics, Sys 5
Linux:
GNU, BSD/Posix
How to use this reference guide
This programming guide is something between a user manual and a tutorial. The information
contained here should be sufficient to get you started with the unix system, but it is far from
file:///C|/Dokumente und Einstellungen/The UNIX programming environment.htm (4 von 198)20.11.2004 11:29:41
The UNIX programming environment
complete.
To use this programming guide, you will need to work through the basics from each chapter. You
will find that there is much more information here than you need straight away, so try not to be
overwhelmed by the amount of material. Use the contents and the indices at the back to find the
information you need. If you are following a one-semester UNIX course, you should probably
concentrate on the following:
● The remainder of this introduction
● The detailed knowledge of the C shell
● An appreciation of the Bourne shell
● A detailed knowledge of Perl, guided by chapter 6. This chapter provides pointers on how to
get started in perl. It is not a substitute for the perl book.
● Everything in chapter 7 about C programming. This chapter is written in note form, since it
is assumed that you know a lot about C programming already.
● A sound appreciation of chapter 8 on network programming.
The only way to learn UNIX is to sit down and try it. As with any new thing, it is a pain to get
started, but once you are started, you will probably come to agree that UNIX contains a wealth of
possibilities, perhaps more than you had ever though was possible or useful!
One of the advantages of the UNIX system is that the entire UNIX manual is available on-line. You
should get used to looking for information in the online manual pages. For instance, suppose you
do not remember how to create a new directory, you could do the following:
nexus% man -k dir
dir ls (1) - list contents of directories
dirname dirname (1) - strip non-directory suffix from file
name
dirs bash (1) - bash built-in commands, see bash(1)
find find (1) - search for files in a directory
hierarchy
ls ls (1) - list contents of directories
mkdir mkdir (1) - make directories
pwd pwd (1) - print name of current/working directory
rmdir rmdir (1) - remove empty directories
The `man -k' command looks for a keyword in the manual and lists all the references it finds.
The command `apropos' is completely equivalent to `man -k'. Having discovered that the
command to create a directory is `mkdir' you can now look up the specific manaul page on
`mkdir' to find out how to use it:
man mkdir
Some but no all of the UNIX commands also have a help option which is activated with the `-h'
or `--help' command-line option.
file:///C|/Dokumente und Einstellungen/The UNIX programming environment.htm (5 von 198)20.11.2004 11:29:41
剩余197页未读,继续阅读
niliuyu
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0