Python在Unix和Linux系统管理中的应用(影印版)
Python在Unix和Linux系统管理中的应用(影印版)
Noah Gift, Jeremy M. Jones
出版时间:2009年04月
页数:433
《Python在Unix和Linux系统管理中的应用》展示了Python语言如何提供一种更加高效的方式来处理Unix和Linux服务器管理工作中的各种任务。本书的每一章都会提出一个特定的管理问题,例如并发或数据备份,然后通过实际的例子提供基于Python的解决方案。你将学习使用Python开发一套属于自己的命令行工具,并用来解决一系列范围很广的问题。

本书作者们还构建了一个可以免费下载的Ubuntu虚拟机。该虚拟机包含了这本书的源代码,还可以用来运行书中的实例,包括SNMP、IPython、SQLAlchemy和许多其他工具。

通过这本书,你将发现Python是怎样帮助你:

* 读入文本文件并提取信息
* 使用线程和派生子进程的选项并发地运行多个任务
* 使用网络工具从一个进程传送信息到另一个进程
* 创建更易互动的可点击图形界面工具
* 通过与SNMP交互来用程序监控大型多个集群机器
* 掌握IPython的命令环境来替代或增强Bash、Korn或Z-Shell的功能
* 将云计算集成到基础架构中并编写一个基于谷歌应用程序引擎的应用
* 利用定制脚本来解决特殊的数据备份的挑战
* 使用Django、SQLAlchemy和Storm对象关系模型来与数据库交互

通过本书及其辅助虚拟机,你将学习如何打包并部署Python应用程序和库文件,以及如何编写在多个Unix和Linux平台下都运行良好的代码。

“这本书适用于Python新手,不管他们是否具有命令环境脚本编写的经验或者总体上相对而言就是编程初学者。Jeremy和Noah都很注意为自己的理由给出支持材料,并且解释这些代码实例在实际中的运用。与许多轻易就让新手不堪重负的编程书籍不同,本书尽一切努力来让这些新手们获得自信和成功。”
——Ruth Suehle和Bascha Harris,Red Hat杂志

Noah Gift在加州理工学院、迪斯尼、Feature Animation和Turner Studios具有十年以上的Unix和Linux开发经验。他是Giftcs和Cloud Seed软件公司的合伙人。

Jeremy M.Jones是Predictix公司的软件工程师,同时也是开源项目Munkware、ediplex和podgrabber的作者。
  1. Foreword
  2. Preface
  3. 1. Introduction
  4. Why Python?
  5. Motivation
  6. The Basics
  7. Executing Statements in Python
  8. Using Functions in Python
  9. Reusing Code with the Import Statement
  10. 2. IPython
  11. Installing IPython
  12. Basic Concepts
  13. Help with Magic Functions
  14. Unix Shell
  15. Information Gathering
  16. Automation and Shortcuts
  17. Summary
  18. 3. Text
  19. Python Built-ins and Modules
  20. Log Parsing
  21. ElementTree
  22. Summary
  23. 4. Documentation and Reporting
  24. Automated Information Gathering
  25. Manual Information Gathering
  26. Information Formatting
  27. Information Distribution
  28. Summary
  29. 5. Networking
  30. Network Clients
  31. Remote Procedure Call Facilities
  32. SSH
  33. Twisted
  34. Scapy
  35. Creating Scripts with Scapy
  36. 6. Data
  37. Introduction
  38. Using the OS Module to Interact with Data
  39. Copying, Moving, Renaming, and Deleting Data
  40. Working with Paths, Directories, and Files
  41. Comparing Data
  42. Merging Data
  43. Pattern Matching Files and Directories
  44. Wrapping Up rsync
  45. Metadata: Data About Data
  46. Archiving, Compressing, Imaging, and Restoring
  47. Using tarfile Module to Create TAR Archives
  48. Using a tarfile Module to Examine the Contents of TAR Files
  49. 7. SNMP
  50. Introduction
  51. Brief Introduction to SNMP
  52. IPython and Net-SNMP
  53. Discovering a Data Center
  54. Retrieving Multiple-Values with Net-SNMP
  55. Creating Hybrid SNMP Tools
  56. Extending Net-SNMP
  57. SNMP Device Control
  58. Enterprise SNMP Integration with Zenoss
  59. 8. OS Soup
  60. Introduction
  61. Cross-Platform Unix Programming in Python
  62. PyInotify
  63. OS X
  64. Red Hat Linux Systems Administration
  65. Ubuntu Administration
  66. Solaris Systems Administration
  67. Virtualization
  68. Cloud Computing
  69. Using Zenoss to Manage Windows Servers from Linux
  70. 9. Package Management
  71. Introduction
  72. Setuptools and Python Eggs
  73. Using easy_install
  74. easy_install Advanced Features
  75. Creating Eggs
  76. Entry Points and Console Scripts
  77. Registering a Package with the Python Package Index
  78. Distutils
  79. Buildout
  80. Using Buildout
  81. Developing with Buildout
  82. virtualenv
  83. EPM Package Manager
  84. 10. Processes and Concurrency
  85. Introduction
  86. Subprocess
  87. Using Supervisor to Manage Processes
  88. Using Screen to Manage Processes
  89. Threads in Python
  90. Processes
  91. Processing Module
  92. Scheduling Python Processes
  93. daemonizer
  94. Summary
  95. 11. Building GUIs
  96. GUI Building Theory
  97. Building a Simple PyGTK App
  98. Building an Apache Log Viewer Using PyGTK
  99. Building an Apache Log Viewer Using Curses
  100. Web Applications
  101. Django
  102. Conclusion
  103. 12. Data Persistence
  104. Simple Serialization
  105. Relational Serialization
  106. Summary
  107. 13. Command Line
  108. Introduction
  109. Basic Standard Input Usage
  110. Introduction to Optparse
  111. Simple Optparse Usage Patterns
  112. Unix Mashups: Integrating Shell Commands into Python Command-Line Tools
  113. Integrating Configuration Files
  114. Summary
  115. 14. Pragmatic Examples
  116. Managing DNS with Python
  117. Using LDAP with OpenLDAP, Active Directory, and More with Python 406
  118. Apache Log Reporting
  119. FTP Mirror
  120. Appendix: Callbacks
  121. Index
书名:Python在Unix和Linux系统管理中的应用(影印版)
作者:Noah Gift, Jeremy M. Jones
国内出版社:中国电力出版社
出版时间:2009年04月
页数:433
书号:978-7-80205-738-8
原版书出版商:O'Reilly Media
Noah Gift
 
Noah Gift是加州州立大学洛杉矶分校的CIS硕士、加州理工学院圣路易斯奥比斯波营养学学士、Apple和LPI认证系统管理员,曾就职于加州理工学院、迪斯尼动画公司、索尼图像和Turner工作室。
在闲暇时间里,他喜欢与妻子Leah、儿子Liam一起弹钢琴和做运动。
Noah Gift has an M.A. in CIS from California State University, Los Angeles, a B.S. in
nutritional science from California Polytechnic San Luis Obispo, is an Apple and LPI
certified sysadmin, and has worked at companies such as Caltech, Disney Feature Animation,
Sony Imageworks, and Turner Studios.
In his free time, he enjoys hanging out with his wife, Leah, and their son, Liam, playing
the piano, and exercising religiously.
 
 
Jeremy M. Jones
 
Jeremy M. Jones是一名软件工程师,现任职于Predictix。他选择的开发工具是Python,而他对shell、Perl也有一定研究,了解Java的相关知识,当前在学习C#。他对函数式编程语言(尤其是OCaml)非常感兴趣。
他是开放源码项目Munkware的开发者,Munkware是一个多生产者/多消费者、事务性、持久队列机制的项目;他还是ediplex的开发者,ediplex是一个EDI(电子数据交换)解析引擎。此外,他也是podgrabber的开发者,podgrabber是一个podcast下载器。以上三个项目都是由Python语言编写。
Jeremy将他的空闲时间花在家庭生活和写作上。他和他的妻子Debra以及两个孩子Zane和Justus住在Georgia(Atlanta的东部)的Conyers,那里有一个名为Genevieve的实验室。
Jeremy所表达的想法和观点仅代表他个人,不代表Predictix的观点。
Jeremy M. Jones is a software engineer who works for Predictix. His weapon of choice
is Python, but he has done some shell, plenty of Perl, a touch of Java, is currently
learning C#, and finds functional programming languages (especially OCaml)
fascinating.
He is the author of the open source projects Munkware, a multiproducer/multiconsumer,
transactional, and persistent queuing mechanism; ediplex, an EDI (electronic
data interchange) parsing engine; and podgrabber, a podcast downloader. All three
projects were written in the Python language.
Jeremy spends his spare time enjoying his family and doing a little writing. He lives in
Conyers, Georgia (just east of Atlanta) with his wife, Debra, two children, Zane and
Justus, and a lab named Genevieve (how Madelinesque).
Opinions and views expressed by Jeremy are his own and not those of Predictix.
 
 
The image on the cover of Python for Unix and Linux System Administration is a boa
constrictor (boa constrictor). Found throughout South and Central America and some
islands in the Caribbean, boa constrictors are non-venomous snakes that can thrive in
a wide array of environments, from deserts to open savannas and wet tropical forests,
but they prefer arid terrain over wet surroundings. They are both terrestrial and arboreal,
but as they get older, they tend to spend more time on the ground.
Boa constrictors have very unique markings that include diamond- and oval-like patterns.
Their scales change colors depending on their habitat, allowing them to hide
from the forest-dwelling animals that hunt them.
In the wild, boa constrictors thrive on small- to medium-size rodents, lizards, bats,
birds, mongooses, squirrels, and have even been known to feast on other mammals as
large as ocelots. Being cold-blooded and slow moving, boas can go up to a week without
eating after capturing large prey. They are solitary and nocturnal hunters, with heatsensitive
pads on their heads to help them hunt. Particularly fond of bats, boas will
hang in trees and from the mouths of caves waiting for them to fly by, then they can
grab the bats with their mouths. Not surprisingly, boa constrictors kill by constriction.
The snake wraps its body around its prey in coils, tightening its grip each time the victim
breathes out, eventually suffocating it to death.
Boas are a common attraction in zoos, and they are even relatively common pets. In
fact, thousands of dollars are made every year importing them into the U.S. In South
America, they are revered as “destroyers of rodents” and are often domesticated for
that reason. Boa constrictors grow quite tame in captivity and can live there as such for
20–30 years. Hunted for the exotic pet trade and their decorative markings, some boa
constrictors are endangered and have protected status.
Boa constrictors are seasonal breeders. To attract males, females emit a scent from their
cloacas, which is the chamber into which the intestinal and urogenital tracts discharge.
Fertilization happens internally, and females can give birth to up to 60 live babies at
one time. Significantly smaller than their anaconda cousins, newborn boas average 2
feet in length and can grow up to 13 feet long and weigh more than 100 pounds. Found
in South America, the largest boa constrictor on record was 18 feet!