DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > PBS Combines Features of Bash with Power of Python

PBS Combines Features of Bash with Power of Python

Chris Smith user avatar by
Chris Smith
·
Jan. 31, 12 · Web Dev Zone · Interview
Like (0)
Save
Tweet
2.23K Views

Join the DZone community and get the full member experience.

Join For Free
PBS, a new Python extension available for developers, aims to provide the best features of Bash with the flexibility of Python.  Far from "a collection of system commands implemented in Python," importing PBS provides a dynamic lookup mechanism that makes system programs available to a shell-style script.

Andrew Moffat provides several examples of how useful PBS can be, including this one dealing with Exceptions:

Exceptions are dynamically generated based on the return code of the command. This lets you catch a specific return code, or catch all error return codes through the base class ErrorReturnCode:

try: print ls("/some/non-existant/folder")
except ErrorReturnCode_2:
    print "folder doesn't exist!"
    create_the_folder()
except ErrorReturnCode:
    print "unknown error"
    exit(1)
-- Andrew Moffat

Other examples provided by Moffat on his GitHub page include:

  • Executing Commands
  • Piping
  • Finding Commands
  • Commandline Arguments
  • Weirdly-names Commands

PBS requires Python 2.5.1 or higher and has been released under the Apache License 2.0.


Python (language) Bash (Unix shell)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Python 101: Equality vs. Identity
  • Data Mesh — Graduating Your Data to Next Level
  • Vaadin Apps as Native Executables Using Quarkus Native
  • Complete Guide to TestOps

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo