Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

PBS Combines Features of Bash with Power of Python

DZone's Guide to

PBS Combines Features of Bash with Power of Python

· Web Dev Zone
Free Resource

Make the transition to Node.js if you are a Java, PHP, Rails or .NET developer with these resources to help jumpstart your Node.js knowledge plus pick up some development tips.  Brought to you in partnership with IBM.

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.


Learn why developers are gravitating towards Node and its ability to retain and leverage the skills of JavaScript developers and the ability to deliver projects faster than other languages can.  Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}