Send history of current host to some other host over ssh

Sometimes I want to save the history of current host on another host. This is to ensure that I can use copy/paste on other host to run the commands. To this, I found a simple solution –

history| ssh <user>@<host> 'cat - > /tmp/history'

And on the new host, you can find the history in file “/tmp/history”, cool :). Now I can quick edit this file to create this as shell script as well if required. How cool is that.

send mail using telnet from script

If you have no other option but to use telnet with authentication to send mail 🙂

 ( echo "ehlo"
sleep 1
auth login
sleep 1
$(echo username |base64)
sleep 1
$(echo password |base64)
sleep 1
mail from: from-address
sleep 1
rcpt to: recepient
sleep 1
sleep 1
subject: test 
test mail

exit ) |telnet server port

ansible with docker dynamic inventory

So, I have a few dockers. Every now and then I want to run some command on all of them. Doing ‘docker exec’ is tiresome. I found this neat solution with ansible that I thought I should share with you.

To get started, you need to have the “” script. This script will be used as python script inventory for ansible. So, use the following command and get the script:

curl '' -o docker.p

Once done, check that all is well, with :


You should not get any errors or warnings and see a list of dockers running on your host. If you get error for docker-py then you can install the same with :

pip install docker-py

And now is the good time to open the script to check the documentation. It adds all the docker hosts as entry in itself. But cool  thing I liked is the fact that it creates a group for all running dockers – which is very very useful.


Now, if I want to set the Timezone (TZ) on all the running dockers in one go, I can do this:

ansible -i -m shell -a 'rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime' running

And just in case, the above does not work for you and you have a common username/password on all the machines, then another thing you would love is following:

# Export the docker host. If that is localhost, then you do not need this.
export DOCKER_HOST=tcp://
# This is GOOD to set option. This is the default IP address for docker
# and setting this to first IP address of the docker network is good idea
# that would ensure that ansible can login to each docker.
# And note - you need to have ssh running on all the dockers for the commands to work
ansible -i -m setup -u root  -a 'filter=ansible_eth[0-2]'  all