SlideShare a Scribd company logo
Python

for Linux system administration




       (yes, this is a commercial)




              Vern Ceder
            Fort Wayne LUG
            Fort Wayne, IN
Instead of?

the “official” languages for sysamins



    bash* (and awk and sed)
       *or your favorite similar shell


                   perl
       (if you don't believe me,
             ask O'Reilly)
http://www.oreillyschool.com/courses/asac4/
A scripting language should

      handle input & output

 process text – search, replace,
      pattern matching, etc.

       traverse filesystems

use system utilities and libraries
              (glue)
What's wrong with
   bash & perl?



 Nothing, really...
bash


is a great glue language

pipes things like a champ

has a ton of utilities
  (the whole system, in fact)
awk and sed


handle strings brilliantly
perl


combines it all...
but...

  bash is a pain when things
          get complex

         sed is tricky

    perl makes my head hurt

(I always have rather liked awk)
So what about Python?

      handles strings well

        is a good “glue”

   “batteries included” → I/O,
         filesystem, etc

large collection of external libs
Python also

   is very readable
(and easy to maintain)

    is expressive

   is easy to grasp

is either OO (or not)

        is fun
everyone's doing it

        Redhat

        Ubuntu

        Google

   etc, etc, etc...
but...
         (there's always a “but”)


regular expressions aren't built-in

   not (quite) as common as perl
and let's talk about




the elephant in the room
indentation

yes, Python uses indentation
       to organize code

 it makes code more readable

it's no weirder than {} or @$%



         get over it
strings
some built-in string methods
   split             lower
   strip             upper
    join            isdigit
  replace          swapcase
    find          expandtabs
   count             center
startswith      encode/decode
 endswith            format
for example

             to do what wc does:
#!/usr/bin/env python

import sys
data = sys.stdin.read()
chars = len(data)
words = len(data.split())
lines = len(data.split('n'))
print ("{0}   {1}   {2}".format(lines, words, chars))

doc@paladin:~/work/olf$ ./wc.py < wc.py
12   22   189
or number of occurrences?
             in bash (not mine):
doc@pal:~/olf$ tr " " "n" <    wc.py | grep len | wc -w
3
                   in Python:
#!/usr/bin/env python
import sys
data = sys.stdin.read()
print data.count(sys.argv[1])

doc@paladin:~/work/olf$ ./num_occur.py len < wc.py
3
regular expressions

                   re module

         syntax similar to perl
import re
>>> re.findall("[Ll]en", "len is the Length")
['len', 'Len']
exception handling
y = 10
try:
    x = y / 0
except ZeroDivisionError, e:
    print e
integer division or modulo by zero
glue

 multiple ways to call other
programs and pipe the results
  sys.stdin, sys.stdout, sys.stderr

      os.system(), os.spawnl()

         subprocess.call()

         subprocess.Popen()
Modules: subprocess
from subprocess import *
p = Popen(["ls", "-l"], stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
files, directories and more
        the os and sys modules
os.environ         sys.argv
os.getcwd          sys.stdin
os.chmod           sys.stdout
os.chown           sys.stderr
os.link            sys.platform
os.mkdir           sys.exit
os.remove
os.rename
Modules: os

                os.walk()
import os
>>> for x in os.walk('.'):
...     print x
...
('.', ['emptydir'], [ 'chinese-python-
poster.jpg', 'olf_proposal.txt', 'wc.py',
'olf.odp', 'shell.png', 'olf.txt',
'Pil.gif', 'adminscripting.png',
'num_occur.py'])
('./emptydir', [], [])
Modules: os.path

     exists
     getmtime
     isfile
     isdir
     islink
     ismount
     samefile
     split
command line arguments

           sys.argv
      list of all arguments

           optparse
  parsing all types of arguments

  returns options and parameters

         automatic help
Modules: others

databases – sqlite3 and others

             fork

          threading
ssh – paramiko
#!/usr/bin/env python
import paramiko

hostname = 'localhost'
port = 22
username = 'test'
password = 'password'

paramiko.util.log_to_file('paramiko.log')
    s = paramiko.SSHClient()
    s.load_system_host_keys()
    s.connect(hostname, port, username, password)
    stdin, stdout, stderr = s.exec_command('ifconfig')
    print stdout.read()
    s.close()
daemons

               python-daemon
import daemon
from spam import main_program
with daemon.DaemonContext():
main_program
ctypes
         load and use C libraries
          also works with Windows DLL's

>>> from ctypes import *
>>> libc = CDLL("libc.so.6")
>>> libc.printf("hello %sn", "Python")
hello Python
13
>>> print libc.time(None)
1253757776
>>> import datetime
>>> datetime.datetime.fromtimestamp(libc.time(None))
datetime.datetime(2009, 9, 23, 22, 5, 56)
A 2 line HTTP server
from  http.server import HTTPServer,
              SimpleHTTPRequestHandler
server = HTTPServer(("",8000),
           SimpleHTTPRequestHandler)
server.serve_forever()
What about Python 3?

it's a better language than 2.x

  it's not backward compatible

it's supported by the developers

         it's the future

it's not here (for sysadmins) yet
ipython, the uber shell

             extensive history

        usable as a system shell

        http://ipython.scipy.org
In [1]: print "hello"
------> print("hello")
hello

In [2]: ls
 adminscripting.png      olf.odp   Pil.gif
nd
Quick Python Book, 2            ed

           covering Python 3

        due out late this year
          http://www.manning.com/ceder
World's largest Python conference
             Talks

                         PyCon 2010
                                                             Open Space
         Tutorials
                                                             Hands-On Lab
        Lightning
          Talks           Feb. 17-25                          Exhibit Hall

        Keynotes
                          Atlanta, GA                           Sprints


                            NOW with
                         Poster sessions!




                         us.pycon.org
Photo: james.rintamaki
License: Attribution-
Share Alike 2.0
Generic
Resources
                  & contact info

    Python for Unix and Linux System Administration,
     Noah Gift, Jeremy M. Jones, O'Reilly Media 2008

          Pro Python System Administration,
      Rytis Sileika, Apress, (not yet published)

   “Python for system administrators”, James Knowlton,
                 IBM DeveloperWorks, 2007
http://www.ibm.com/developerworks/aix/library/au-python/

   Python Cookbook, Martelli, Ravenscroft & Ascher,
                  O'Reilly Media 2005
Contact info


http://tech.canterburyschool.org/tech/VernCeder

         http://www.manning.com/ceder

               vceder@gmail.com

More Related Content

PDF
Building better Node.js applications on MariaDB
MariaDB plc
 
PDF
실전! AWS 하이브리드 네트워킹 (AWS Direct Connect 및 VPN 데모 세션) - 강동환, AWS 솔루션즈 아키텍트:: A...
Amazon Web Services Korea
 
PDF
AWS를 이용한 렌더링 아키텍처 및 사용 사례 :: 박철수 솔루션즈 아키텍트 :: AWS Media Day
Amazon Web Services Korea
 
PDF
AWS로 게임의 공통 기능 개발하기! - 채민관, 김민석, 한준식 :: AWS Game Master 온라인 세미나 #2
Amazon Web Services Korea
 
PDF
AWS Summit Seoul 2023 |Datadog을 활용한 AWS 서버리스 Observability
Amazon Web Services Korea
 
PDF
AWS Direct Connect 를 통한 하이브리드 클라우드 아키텍쳐 설계 - 김용우 솔루션즈 아키텍트, AWS :: AWS Summit...
Amazon Web Services Korea
 
PDF
AWS 비용, 어떻게 사용하고 계신가요? - 비용 최적화를 위한 AWS의 다양한 툴 알아보기 – 허경원, AWS 클라우드 파이낸셜 매니저:...
Amazon Web Services Korea
 
PDF
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
Amazon Web Services Korea
 
Building better Node.js applications on MariaDB
MariaDB plc
 
실전! AWS 하이브리드 네트워킹 (AWS Direct Connect 및 VPN 데모 세션) - 강동환, AWS 솔루션즈 아키텍트:: A...
Amazon Web Services Korea
 
AWS를 이용한 렌더링 아키텍처 및 사용 사례 :: 박철수 솔루션즈 아키텍트 :: AWS Media Day
Amazon Web Services Korea
 
AWS로 게임의 공통 기능 개발하기! - 채민관, 김민석, 한준식 :: AWS Game Master 온라인 세미나 #2
Amazon Web Services Korea
 
AWS Summit Seoul 2023 |Datadog을 활용한 AWS 서버리스 Observability
Amazon Web Services Korea
 
AWS Direct Connect 를 통한 하이브리드 클라우드 아키텍쳐 설계 - 김용우 솔루션즈 아키텍트, AWS :: AWS Summit...
Amazon Web Services Korea
 
AWS 비용, 어떻게 사용하고 계신가요? - 비용 최적화를 위한 AWS의 다양한 툴 알아보기 – 허경원, AWS 클라우드 파이낸셜 매니저:...
Amazon Web Services Korea
 
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
Amazon Web Services Korea
 

What's hot (20)

PDF
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
Amazon Web Services Korea
 
PDF
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
Amazon Web Services Korea
 
PDF
서버리스 앱 배포 자동화 (김필중, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
Amazon Web Services Korea
 
PDF
AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
Amazon Web Services Korea
 
PDF
AWS CLOUD 2017 - AWS 기반 하이브리드 클라우드 환경 구성 전략 (김용우 솔루션즈 아키텍트)
Amazon Web Services Korea
 
PDF
AWS Fargate on EKS 실전 사용하기
AWSKRUG - AWS한국사용자모임
 
PDF
Kali linux tutorial
HarikaReddy115
 
PPTX
Packet Capture on AWS
2nd Sight Lab
 
PDF
Amazon EKS를 위한 AWS CDK와 CDK8s 활용법 - 염지원, 김광영 AWS 솔루션즈 아키텍트 :: AWS Summit Seou...
Amazon Web Services Korea
 
PDF
AWS 상의 컨테이너 서비스 소개 ECS, EKS - 이종립 / Principle Enterprise Evangelist @베스핀글로벌
BESPIN GLOBAL
 
PPTX
Kubernetes #6 advanced scheduling
Terry Cho
 
PDF
CloudWatch 성능 모니터링과 신속한 대응을 위한 노하우 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
Amazon Web Services Korea
 
PPTX
AWS CloudFront 가속 및 DDoS 방어
Kyle(KY) Yang
 
PDF
Massive service basic
DaeMyung Kang
 
PDF
AWS Transit Gateway를 통한 Multi-VPC 아키텍처 패턴 - 강동환 솔루션즈 아키텍트, AWS :: AWS Summit ...
Amazon Web Services Korea
 
PPTX
Mastering Java Bytecode With ASM - 33rd degree, 2012
Anton Arhipov
 
PDF
Chaos Engineering 시작하기 - 윤석찬 (AWS 테크에반젤리스트) :: 한국 카오스엔지니어링 밋업
Channy Yun
 
PDF
Power shell saldırılarının ayak i̇zleri
Adeo Security
 
PDF
천만 사용자를 위한 AWS 클라우드 아키텍처 진화하기::이창수::AWS Summit Seoul 2018
Amazon Web Services Korea
 
PDF
[WhaTap DevOps Day] 세션 6 : 와탭랩스 DevOps 이야기
WhaTap Labs
 
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
Amazon Web Services Korea
 
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
Amazon Web Services Korea
 
서버리스 앱 배포 자동화 (김필중, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
Amazon Web Services Korea
 
AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
Amazon Web Services Korea
 
AWS CLOUD 2017 - AWS 기반 하이브리드 클라우드 환경 구성 전략 (김용우 솔루션즈 아키텍트)
Amazon Web Services Korea
 
AWS Fargate on EKS 실전 사용하기
AWSKRUG - AWS한국사용자모임
 
Kali linux tutorial
HarikaReddy115
 
Packet Capture on AWS
2nd Sight Lab
 
Amazon EKS를 위한 AWS CDK와 CDK8s 활용법 - 염지원, 김광영 AWS 솔루션즈 아키텍트 :: AWS Summit Seou...
Amazon Web Services Korea
 
AWS 상의 컨테이너 서비스 소개 ECS, EKS - 이종립 / Principle Enterprise Evangelist @베스핀글로벌
BESPIN GLOBAL
 
Kubernetes #6 advanced scheduling
Terry Cho
 
CloudWatch 성능 모니터링과 신속한 대응을 위한 노하우 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
Amazon Web Services Korea
 
AWS CloudFront 가속 및 DDoS 방어
Kyle(KY) Yang
 
Massive service basic
DaeMyung Kang
 
AWS Transit Gateway를 통한 Multi-VPC 아키텍처 패턴 - 강동환 솔루션즈 아키텍트, AWS :: AWS Summit ...
Amazon Web Services Korea
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Anton Arhipov
 
Chaos Engineering 시작하기 - 윤석찬 (AWS 테크에반젤리스트) :: 한국 카오스엔지니어링 밋업
Channy Yun
 
Power shell saldırılarının ayak i̇zleri
Adeo Security
 
천만 사용자를 위한 AWS 클라우드 아키텍처 진화하기::이창수::AWS Summit Seoul 2018
Amazon Web Services Korea
 
[WhaTap DevOps Day] 세션 6 : 와탭랩스 DevOps 이야기
WhaTap Labs
 
Ad

Viewers also liked (20)

PDF
Python and sysadmin I
Guixing Bai
 
PDF
Python for-unix-and-linux-system-administration
Victor Marcelino
 
ODP
Programming Under Linux In Python
Marwan Osman
 
PDF
Server Administration in Python with Fabric, Cuisine and Watchdog
ConFoo
 
PPT
PyOWM - my first open source project
Claudio Sparpaglione
 
PDF
Programación Segura en python. Owasp Venezuela
Eliezer Jose Romero Carrasquero
 
PDF
Introduction to the rapid prototyping with python and linux for embedded systems
Naohiko Shimizu
 
PDF
Integrando mis librerías C++ con Python
Carlos Gustavo Ruiz
 
PDF
Real world Django deployment using Chef
coderanger
 
PDF
Linux system administration - part-2
M.M.Rahman Munna, Linux, VMware and Mail Server Expert
 
ODP
Python en Android,Charla del FUDcon Latam 2012
Ernesto Crespo
 
PPTX
Automated Deployment with Fabric
tanihito
 
PDF
Final Internship presentation
Anjan Bhattrai
 
PDF
TDC2016SP - Trilha Linux Embarcado
tdc-globalcode
 
PPTX
Final Internship Presentation
Minhas Kamal
 
PDF
Architecting a Scalable Hadoop Platform: Top 10 considerations for success
DataWorks Summit
 
PPT
Python Deployment with Fabric
andymccurdy
 
PPTX
Internship final presentation GraphicPeople
Samsuddoha Sams
 
PPTX
Where to Deploy Hadoop: Bare Metal or Cloud?
DataWorks Summit
 
PDF
20150306 파이썬기초 IPython을이용한프로그래밍_이태영
Tae Young Lee
 
Python and sysadmin I
Guixing Bai
 
Python for-unix-and-linux-system-administration
Victor Marcelino
 
Programming Under Linux In Python
Marwan Osman
 
Server Administration in Python with Fabric, Cuisine and Watchdog
ConFoo
 
PyOWM - my first open source project
Claudio Sparpaglione
 
Programación Segura en python. Owasp Venezuela
Eliezer Jose Romero Carrasquero
 
Introduction to the rapid prototyping with python and linux for embedded systems
Naohiko Shimizu
 
Integrando mis librerías C++ con Python
Carlos Gustavo Ruiz
 
Real world Django deployment using Chef
coderanger
 
Linux system administration - part-2
M.M.Rahman Munna, Linux, VMware and Mail Server Expert
 
Python en Android,Charla del FUDcon Latam 2012
Ernesto Crespo
 
Automated Deployment with Fabric
tanihito
 
Final Internship presentation
Anjan Bhattrai
 
TDC2016SP - Trilha Linux Embarcado
tdc-globalcode
 
Final Internship Presentation
Minhas Kamal
 
Architecting a Scalable Hadoop Platform: Top 10 considerations for success
DataWorks Summit
 
Python Deployment with Fabric
andymccurdy
 
Internship final presentation GraphicPeople
Samsuddoha Sams
 
Where to Deploy Hadoop: Bare Metal or Cloud?
DataWorks Summit
 
20150306 파이썬기초 IPython을이용한프로그래밍_이태영
Tae Young Lee
 
Ad

Similar to Python for Linux System Administration (20)

PDF
Programming with Python - Basic
Mosky Liu
 
PDF
PyCon 2013 : Scripting to PyPi to GitHub and More
Matt Harrison
 
PDF
How to write a well-behaved Python command line application
gjcross
 
PPTX
Introduction to Python for Security Professionals
Andrew McNicol
 
PDF
Intro to Python Workshop San Diego, CA (January 19, 2013)
Kendall
 
ODP
Learn python
Kracekumar Ramaraju
 
PDF
Introduction to python 3
Youhei Sakurai
 
PDF
[FREE PDF sample] Programming Python with CD 2nd Edition Mark Lutz ebooks
raginmoradtx
 
PDF
Get Programming Python with CD 2nd Edition Mark Lutz free all chapters
gricharnasg5
 
PPTX
Overview of python misec - 2-2012
Tazdrumm3r
 
PPT
Unix
Sudharsan S
 
PDF
PyCon 2011: IronPython Command Line
Lecturer UC Davis & Northwestern
 
PPTX
Overview of Python - Bsides Detroit 2012
Tazdrumm3r
 
PDF
Python Cookbook 1st Edition Martelli Alex Ascher David
bamenhamvai63
 
PDF
Programming Python 3rd ed Edition Mark Lutz
belisdagelre
 
PPT
Introduction to python
Syed Zaid Irshad
 
PDF
Programming Python 3rd ed Edition Mark Lutz
seebjqsmiq828
 
PDF
PythonNotes1.pdf
Shaikfiza5
 
PDF
Class 1: Welcome to programming
Marc Gouw
 
PDF
Linux Basics
Team-VLSI-ITMU
 
Programming with Python - Basic
Mosky Liu
 
PyCon 2013 : Scripting to PyPi to GitHub and More
Matt Harrison
 
How to write a well-behaved Python command line application
gjcross
 
Introduction to Python for Security Professionals
Andrew McNicol
 
Intro to Python Workshop San Diego, CA (January 19, 2013)
Kendall
 
Learn python
Kracekumar Ramaraju
 
Introduction to python 3
Youhei Sakurai
 
[FREE PDF sample] Programming Python with CD 2nd Edition Mark Lutz ebooks
raginmoradtx
 
Get Programming Python with CD 2nd Edition Mark Lutz free all chapters
gricharnasg5
 
Overview of python misec - 2-2012
Tazdrumm3r
 
PyCon 2011: IronPython Command Line
Lecturer UC Davis & Northwestern
 
Overview of Python - Bsides Detroit 2012
Tazdrumm3r
 
Python Cookbook 1st Edition Martelli Alex Ascher David
bamenhamvai63
 
Programming Python 3rd ed Edition Mark Lutz
belisdagelre
 
Introduction to python
Syed Zaid Irshad
 
Programming Python 3rd ed Edition Mark Lutz
seebjqsmiq828
 
PythonNotes1.pdf
Shaikfiza5
 
Class 1: Welcome to programming
Marc Gouw
 
Linux Basics
Team-VLSI-ITMU
 

Python for Linux System Administration

  • 1. Python for Linux system administration (yes, this is a commercial) Vern Ceder Fort Wayne LUG Fort Wayne, IN
  • 2. Instead of? the “official” languages for sysamins bash* (and awk and sed) *or your favorite similar shell perl (if you don't believe me, ask O'Reilly)
  • 4. A scripting language should handle input & output process text – search, replace, pattern matching, etc. traverse filesystems use system utilities and libraries (glue)
  • 5. What's wrong with bash & perl? Nothing, really...
  • 6. bash is a great glue language pipes things like a champ has a ton of utilities (the whole system, in fact)
  • 7. awk and sed handle strings brilliantly
  • 9. but... bash is a pain when things get complex sed is tricky perl makes my head hurt (I always have rather liked awk)
  • 10. So what about Python? handles strings well is a good “glue” “batteries included” → I/O, filesystem, etc large collection of external libs
  • 11. Python also is very readable (and easy to maintain) is expressive is easy to grasp is either OO (or not) is fun
  • 12. everyone's doing it Redhat Ubuntu Google etc, etc, etc...
  • 13. but... (there's always a “but”) regular expressions aren't built-in not (quite) as common as perl
  • 14. and let's talk about the elephant in the room
  • 15. indentation yes, Python uses indentation to organize code it makes code more readable it's no weirder than {} or @$% get over it
  • 16. strings some built-in string methods split lower strip upper join isdigit replace swapcase find expandtabs count center startswith encode/decode endswith format
  • 17. for example to do what wc does: #!/usr/bin/env python import sys data = sys.stdin.read() chars = len(data) words = len(data.split()) lines = len(data.split('n')) print ("{0} {1} {2}".format(lines, words, chars)) doc@paladin:~/work/olf$ ./wc.py < wc.py 12 22 189
  • 18. or number of occurrences? in bash (not mine): doc@pal:~/olf$ tr " " "n" < wc.py | grep len | wc -w 3 in Python: #!/usr/bin/env python import sys data = sys.stdin.read() print data.count(sys.argv[1]) doc@paladin:~/work/olf$ ./num_occur.py len < wc.py 3
  • 19. regular expressions re module syntax similar to perl import re >>> re.findall("[Ll]en", "len is the Length") ['len', 'Len']
  • 20. exception handling y = 10 try: x = y / 0 except ZeroDivisionError, e: print e integer division or modulo by zero
  • 21. glue multiple ways to call other programs and pipe the results sys.stdin, sys.stdout, sys.stderr os.system(), os.spawnl() subprocess.call() subprocess.Popen()
  • 22. Modules: subprocess from subprocess import * p = Popen(["ls", "-l"], stdout=PIPE, stderr=PIPE) out, err = p.communicate()
  • 23. files, directories and more the os and sys modules os.environ sys.argv os.getcwd sys.stdin os.chmod sys.stdout os.chown sys.stderr os.link sys.platform os.mkdir sys.exit os.remove os.rename
  • 24. Modules: os os.walk() import os >>> for x in os.walk('.'): ... print x ... ('.', ['emptydir'], [ 'chinese-python- poster.jpg', 'olf_proposal.txt', 'wc.py', 'olf.odp', 'shell.png', 'olf.txt', 'Pil.gif', 'adminscripting.png', 'num_occur.py']) ('./emptydir', [], [])
  • 25. Modules: os.path exists getmtime isfile isdir islink ismount samefile split
  • 26. command line arguments sys.argv list of all arguments optparse parsing all types of arguments returns options and parameters automatic help
  • 27. Modules: others databases – sqlite3 and others fork threading
  • 28. ssh – paramiko #!/usr/bin/env python import paramiko hostname = 'localhost' port = 22 username = 'test' password = 'password' paramiko.util.log_to_file('paramiko.log') s = paramiko.SSHClient() s.load_system_host_keys() s.connect(hostname, port, username, password) stdin, stdout, stderr = s.exec_command('ifconfig') print stdout.read() s.close()
  • 29. daemons python-daemon import daemon from spam import main_program with daemon.DaemonContext(): main_program
  • 30. ctypes load and use C libraries also works with Windows DLL's >>> from ctypes import * >>> libc = CDLL("libc.so.6") >>> libc.printf("hello %sn", "Python") hello Python 13 >>> print libc.time(None) 1253757776 >>> import datetime >>> datetime.datetime.fromtimestamp(libc.time(None)) datetime.datetime(2009, 9, 23, 22, 5, 56)
  • 31. A 2 line HTTP server from http.server import HTTPServer, SimpleHTTPRequestHandler server = HTTPServer(("",8000), SimpleHTTPRequestHandler) server.serve_forever()
  • 32. What about Python 3? it's a better language than 2.x it's not backward compatible it's supported by the developers it's the future it's not here (for sysadmins) yet
  • 33. ipython, the uber shell extensive history usable as a system shell http://ipython.scipy.org In [1]: print "hello" ------> print("hello") hello In [2]: ls adminscripting.png olf.odp Pil.gif
  • 34. nd Quick Python Book, 2 ed covering Python 3 due out late this year http://www.manning.com/ceder
  • 35. World's largest Python conference Talks PyCon 2010 Open Space Tutorials Hands-On Lab Lightning Talks Feb. 17-25 Exhibit Hall Keynotes Atlanta, GA Sprints NOW with Poster sessions! us.pycon.org Photo: james.rintamaki License: Attribution- Share Alike 2.0 Generic
  • 36. Resources & contact info Python for Unix and Linux System Administration, Noah Gift, Jeremy M. Jones, O'Reilly Media 2008 Pro Python System Administration, Rytis Sileika, Apress, (not yet published) “Python for system administrators”, James Knowlton, IBM DeveloperWorks, 2007 http://www.ibm.com/developerworks/aix/library/au-python/ Python Cookbook, Martelli, Ravenscroft & Ascher, O'Reilly Media 2005