Invoking shell commands

Hello,

I am happy to let you know about a new capability in Zato that lets you easily invoke shell commands or other command-line tools to build APIs around programs that are available from the command line only.

This is useful when there are no APIs accessible at all for a particular system of if using command-line programs is more efficient and productive.

Below is a basic example and full documentation is here. Make sure to install the latest updates to have access to this feature.

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class MyService(Service):
    def handle(self):

        # Command to execute ..
        command = 'cd /tmp && myprogram --hello=world'

        # .. invoke it now ..
        result = self.commands.invoke(command)

        # .. and log basic information about what we received.
        self.logger.info('Is OK     -> %s', result.is_ok)
        self.logger.info('Exit code -> %s', result.exit_code)
        self.logger.info('Stdout    -> %s', result.stdout)
        self.logger.info('Stderr    -> %s', result.stderr)