Prerequisites

本文介绍了一本面向Web应用编程人员的书籍。使用该书需掌握Visual Basic等编程语言、关系数据库概念,熟悉Windows 2000及以上系统和IIS。还列出所需工具,如SQL Server、.NET Framework等,给出运行要求,并对如何充分利用该书提出建议。
This book is designed for programmers who need to know how to program a Web
application. If you are a programmer and/or Web designer who has some
experience with VBScript or ColdFusion, you will get a lot out of this
book. Even if you're not, there is enough in here to get you started. To
get the most out of this book, it is recommended that you have experience
using a programming language such as Visual Basic 6.0. Some experience with
Visual Basic .NET would be helpful, but it's not required. You should also
be familiar with relational database concepts and have access to the
Northwind sample database that comes with SQL Server and Access. You must
be familiar with Windows 2000, or later, and have access to Windows NT,
Windows 2000, or Windows XP to effectively use this book. Familiarity with
IIS is also recommended, because this book will assume you know how to set
up virtual directories in IIS.

Assumptions
You will need several tools at your disposal so you can try out the many
exercises contained in this book. Here is a list of the tools you should
have on your computer:

Microsoft SQL Server 7.0 or later or Microsoft Access

The Northwind sample database, which comes with SQL Server and Access

Microsoft Windows 2000, or XP

Microsoft .NET Common Language Runtime (CLR) Framework SDK

Microsoft Visual Studio .NET

Microsoft Mobile Internet Toolkit (optional)

Getting and Running .NET
The .NET Framework and the Visual Studio .NET IDE can both be purchased
from many vendors, including directly from Microsoft. Although the .NET
Framework will run on Microsoft Windows XP, Windows 2000, Windows NT 4.0,
Windows 98 second edition, and Windows Millennium Edition (Windows Me),
you'll need to have Windows NT with Service Pack 6, Windows 2000, Windows
XP, or Windows .NET Server in order to develop applications. Microsoft
Internet Explorer 6.0 or later is required. For server-side installs,
Microsoft Data Access Components 2.7 is required. You need at least a PII
450MHz processor with a minimum of 128MB of RAM and at least 800x600
resolution.

You will find that you need at least a PIII 650MHz processor with 384MB of
RAM or better to be really productive. The more memory you have, the better
off you will be. Given the choice, adding memory should have a higher
priority than upgrading your processor.

Making the Most of This Book
To download the examples discussed in this book, and to find updates and
fixes, visit our Web site, www.pdsa.com/aspnetjumpstart Because this book
focuses on building an application that looks and feels like a simple
business-oriented Web site, you'll get the flavor of the types of issues
that will affect every ASP.NET developer. Rather than focusing on features
or technology, we've focused on tasks and solutions. Although there may be
other ways to accomplish some of the techniques we've proposed in this
book, given the examples shown here, you'll have a running head start
toward building your own sites and applications.

We suggest that you work your way through this book, from start to finish.
There may be some chapters along the way that cover material you're already
familiar with (for example, the chapters on HTML and XML). In that case,
skim on past. Don't worry about missing out on steps in building the sample
application梬e've included, along with the sample application, a finished
version of the application after each chapter. If you skip a chapter, you
can simply copy the contents of the finished version for the chapter into
your working folder. (See Chapter 1, "Getting Started with the Sample
Application," for more details.) In a perfect world, after working through
the examples in each chapter, you would take the time to review the
documentation on the objects and techniques covered and then add your own
functionality to the application
`check_prerequisites()` 函数是脚本的**前置条件检查器**,用于验证执行环境是否满足要求。以下是详细解析: --- ### **函数功能** 1. **检查文件列表是否存在** - 验证 `$FILE_LIST`(默认 `file_list.txt`)是否可读 - 若不存在则记录错误日志并退出(状态码1) 2. **检查源目录是否存在** - 验证 `$SOURCE_DIR`(默认 `/root/a`)是否可访问 - 若不存在则记录错误日志并退出 3. **依赖日志系统** - 通过 `log()` 函数记录检查结果(ERROR级别会自动输出到stderr) --- ### **代码逐行解析** ```bash check_prerequisites() { # 检查文件列表是否存在 if [ ! -f "$FILE_LIST" ]; then log "文件列表 $FILE_LIST 不存在" "ERROR" # 记录日志 exit 1 # 立即终止脚本 fi # 检查源目录是否存在 if [ ! -d "$SOURCE_DIR" ]; then log "源目录 $SOURCE_DIR 不存在" "ERROR" exit 1 fi } ``` --- ### **关键逻辑** | 检查项 | 条件表达式 | 错误处理方式 | |-----------------------|--------------------|----------------------------------| | 文件列表是否存在 | `[ ! -f "$FILE_LIST" ]` | 记录ERROR日志 → 退出脚本 | | 源目录是否存在 | `[ ! -d "$SOURCE_DIR" ]` | 记录ERROR日志 → 退出脚本 | --- ### **设计特点** 1. **快速失败(Fail Fast)** - 任何检查不通过立即终止脚本,避免后续操作出现未定义行为 2. **明确错误定位** - 日志中会明确标记是文件列表还是源目录的问题 ```plaintext [2023-08-20 15:30:00] [ERROR] 文件列表 file_list.txt 不存在 ``` 3. **与日志系统集成** - 使用 `log()` 而非直接 `echo`,保证错误信息同时输出到日志文件和终端(仅ERROR级别) --- ### **扩展建议** 如需增加其他检查项(如权限验证),可以追加如下代码: ```bash # 检查是否具有写权限(示例) if [ ! -w "$SOURCE_DIR" ]; then log "源目录 $SOURCE_DIR 不可写" "ERROR" exit 1 fi ``` --- ### **典型错误场景** #### 场景1:文件列表丢失 ```bash rm -f file_list.txt ./deploy_tool.sh # 输出: # [ERROR] 文件列表 file_list.txt 不存在 # 脚本退出,状态码1 ``` #### 场景2:源目录错误 ```bash export SOURCE_DIR="/invalid/path" ./deploy_tool.sh # 输出: # [ERROR] 源目录 /invalid/path 不存在 # 脚本退出,状态码1 ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值