Getting something done in Linux with Python, Bash and Java be like this 😛
True, right? For example, you want to write a script which returns IP address of a domain name. Let’s see length of code and time required to write the same in Python, Bash and Java.
In Bash,
/usr/bin/bash host www.easyaslinux.com
In Python,
#!/usr/bin/python import socket try: print socket.gethostbyname('www.easyaslinux.com') except Exception as e: print e
In Java,
package com.myjava.ip; import java.net.InetAddress; import java.net.UnknownHostException; class MyIpByHost { public static void main(String a[]){ try { InetAddress host = InetAddress.getByName("www.easyaslinux.com"); System.out.println(host.getHostAddress()); } catch (UnknownHostException ex) { ex.printStackTrace(); } } }
Now no need of explanation right 😀 ?
You had experience like this? Comment your thoughts below. Also subscribe to this blog so that you don’t miss out anything useful (Checkout Right Sidebar for the Subscription Form) 🙂