Automate interactive shell programs with Python pexpect

Some shell programs expect interactive user input. For example if you spawn a root shell with “su” the program asks your for a password. There is no way to pass this password to “su” as a parameter. Another example is to automate an FTP session: start FTP client, provide user and password, do a couple […]

What is the Best Way to Learn Python in 2016? 2

Have you recently thought about learning Python – but you didn’t know how to start? Are you in doubt whether Python would be the right choice? Why not Java, or Scala, Ruby, Javascript, PHP, C# or Go? Of course there are a lot of good programming languages out there – and every single one has […]

What are the best Python books in 2016? 1

So you think about learning Python? Stop thinking about it – start doing it! Many beginners ask themselves: What would be a good programming language to start with!? Wouldn’t it be better to learn Java – since many enterprises are developing their apps in Java!? What about Ruby? What about Go / C++ / C# […]

python yum check-update howto

If you are running an rpm based Linux system like CentOS you might want to automatically and regularly check if security-updates are available. You can use existing commandline tools or python scripts. This article is about checking if linux host is up-to-date with python yum module – without scraping the cli tool. The yum commandline […]

python call constructor of parent class

python call super constructor

If you want to call the constructor of a parent class you have a couple of options. For example: In this first example we are talking about “new-style” classes. Basically these are classes that inherit from “object” ( class Parent(object) ). In this case you can call the super() method with a reference to Child […]

sed replace newline (or 5 ways to remove line breaks with sed, python, tr, perl, xargs) 1

When you are automating tasks you often come to the point where you have to remove newlines / line breaks from documents or ASCII streams to use this output as parameters for the next steps. There are many options how this can be done. Especially in Big Data streaming you should also consider the performance […]

sed remove line break vs replace newline with other tools

Simply serve local directory via HTTP with python webserver 1

Sometimes you quickly need to exchange some files between networked machines. A really easy way that mostly also works through firewalls is to serve them via a local webserver. Python offers a really simple module for that: python -m SimpleHTTPServer To serve a local directory just run: [email protected]:~$ python -m SimpleHTTPServer Serving HTTP on […]