my net house

WAHEGURU….!

RUN parallel commands on your linux system Using Python

This is really simple Python script that would run on your system if You have to run parallel commands, All you just has to do is Open multiple tabs and run commandson each ab as per your requirement.


#!/usr/bin/env python
import subprocess

command = 'ping .8.8.8.8'
terminal = ['gnome-terminal']

for host in ('server1', 'server2'):
    terminal.extend(['--tab', '-e', '''
        bash -c '
            echo "%(host)s$ %(command)s"
            ssh -t %(host)s "%(command)s"
            read
        '
    ''' % locals()])

subprocess.call(terminal)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: