Pages

Saturday, May 28, 2016

Get all MAC address of Windows System

###Script Starts here###
#Developed By Krunal Patel
#Script Works in Windows System Only
import os
import re
a = os.popen("getmac")
count = "1"
for value in a.readlines():
    m = re.search('[\w][\w]-[\w][\w]-[\w][\w]-[\w][\w]-[\w][\w]-[\w][\w]',value)
    if m:
        print ("MAC Address " + "%s" %count + " = " +"%s" %m.group(0))
        count = int(count) + 1
    else:
        continue
a.close()
###Script Ends Here###

This will give output as per highlighted in yellow marker in below screenshot.



Tuesday, May 17, 2016

Simple "Hello World" script in python for Windows

#!C:\Python27\python.exe -u
a = "Hello World"
print a


Monday, May 16, 2016

Simple "Hello World" Script using Ruby

print("Enter your name or word : ")
name = gets
puts("Hello " + name)



Sunday, May 15, 2016

Simple "hello world!" python script

#!/usr/bin/env python
val = raw_input("Enter Sentanse : ")
print "Welcome", val



Wednesday, May 4, 2016

Bash script to get hostname or ip address from /etc/hosts file, if not add to /etc/hosts file


#!/bin/bash
######Developed By - Krunal Patel(Linux Admin)#####
getent hosts $1 | grep $1
if [ $? == 0 ]; then
echo "hostname or ip address " {$1} " exists in /etc/hosts file"
else
read -p "please enter hostname to be added in /etc/hosts file : " hos
read -p "please enter ip address to be added in /etc/hosts file for $hos : " ipa
echo "$ipa $hos" >> /etc/hosts
fi
######Copyright © Krunal Patel (Shell Script Developer)######

Shell Script Code