Search This Blog

Showing posts with label Computers. Show all posts
Showing posts with label Computers. Show all posts

Using Python to generate configuration file from Excel data

Here it is example how to generate configuration script, e.g. for Cisco or Ericsson, from excel data file. It require xlrd python module for Excel file reading.

import re
import xlrd

def replace_words(text, word_dic):
    """
    take a text and replace words that match a key in a dictionary with
    the associated value, return the changed text
    """
    rc = re.compile('|'.join(map(re.escape, word_dic)))
    def translate(match):
        return word_dic[match.group(0)]
    return rc.sub(translate, text)

"""
preparing the Excel workbook
"""
workbook = xlrd.open_workbook('Book1.xlsx')
worksheet = workbook.sheet_by_name('Sheet1')
num_rows = worksheet.nrows -1
curr_row = 1

while curr_row < num_rows:
    curr_row += 1
    row = worksheet.row(curr_row)
   
    """
    seting up the cell
    """
    hostname = row[0].value
    loopback0 = row[1].value
    ip_address = row[2].value
    netmask = row[3].value
   
    """
    preparing the tamplate
    """
    t = open('Template1.txt')
    tempstr = t.read()
    t.close   
       
    values = {
        '[Hostname]':hostname,
        '[Loopback0]':loopback0,
        '[IP_Address]':ip_address,
        '[Netmask]':netmask,
        }
   
    """
    seting up the output script name,
    replace the variable in template with data, then write it out ...
    """
    outputfile = hostname + "_CONFIG.txt"
    output = replace_words(tempstr, values)
    fout = open(outputfile, "w")
    fout.write(output)
    fout.close
       


Example excerpt from Cisco configuration script, note the bold text that will be replace by script:     

version 12.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname [Hostname]

ip cef

!

interface Loopback0

ip address [Loopback0] 255.255.255.0

!

interface GigabitEthernet0/0

ip address [IP_Address] [Netmask]

duplex auto

speed auto

!


Example data IP


where:
-Book1.xlsx is our database
-Template1.txt is our template

Get exercise file here.

I hope you found it useful :)

Windows 7 error: "The User Profile Service failed the logon”

A friend of mine got problem while log on into his WIndows 7 with following message: "The User Profile Service failed the logon”

After Googling I found solution here. I write it here as my personal  journal.

Start your Windows in Safe Mode

1. Click Start, type regedit in search box, and then hit ENTER.
2. In registry editor, find this value: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList.
3. Locate folder begin with  S-1-5, following by long number.
4. Click on each folder to make sure that the folder contain user profile (ProfileImagePath) you want to fix. Example bellow my username is C:\Users\user
5. If the folder S-1-5 followed by long-numbers that contain user profile, example S-1-5-21-85310989-3826183054-1740520378-1000, ended with .bak, you need to change .bak to .ba. Right-click on thet folder, click rename.
6. If the folder is not ended with .bak, click the folder, doble click State on the right pane, type 0 then click OK.

7. Close registry editor, then restart the Windows.

Free SSL Certificate from StarSSL

Do you need free SSL for your web and email service? You may try StartSSL, they provide 128 SSL for free. To manage your certificate, visit control panel but ensure that SSL client ceritifate is installed on your browser. This client certificate is installed while you signup. Thus, you may only access to your control panel by the browser that installed client certificate. Please refer to its the FAQ page for install, backup certificate.

I just register today, not yet implement it on my system. I hope could update this posting later.

IP addressing tools with Excel

Are you a network designer? You may need this small tool to design IP address.
http://www.interisle.net/sub/topic_areas/IP_address_planning/IP_Address_Plan_Workbook-v101.xls.

This tool provide IP Address planing and inventory. Developed by Chuck Wade from Interisle Consulting Group.

I hope you found this posting useful :).


Windows 7 HyperTerminal

I need HyperTerminal program to configure network equipment, eg. router, switch and Ericsson RBS. Windows 7 does not provide this tools by default. Fortunately, you may still use it by copy from old Windows XP or by download it here.

Example of hypetermianl on WIndows 7. Lack of icon, but work perfectly.

Example accessing Ericsson RBS 6000 using HyperTerminal.
You may also use other alternative, such PuTTY as terminal emulator.   HyperTerminal is still my favorite tool, its easy to use, work well for generate script report, and or execute batch script.

I hope you find this short post useful :).

ASUS X44C-VX007D

I just bought Asus X44C-VX007D notebook yesterday. Here its my brief experience about this value-for-money notebook.
Powered by Intel Celeron Dual Core B800 1.58Ghz give you enough power for day to day job. 2GB of RAM and 320GB HDD enough to do standard computing such MS Office, Web browsing and much more.

Also USB 3.0 very impress me. I copy about 1.5GB data from my external drive within 45seconds, much faster then USB 2.0. And IceCool technology keep the keyboard and mouse-pad area stay cool even after hours.

The fan is very quiet, and Asus provide such a utility to monitor fan speed. Nice.

I need to download display driver since the DVD drive since only provide Windows 7 64-bit drivers. And official web page doesn't provide drivers for WinXP :(.

Equiped with Altec Lansing, the sound is clear enough. And ELAN touchpad provide advance feature such zooming, rotating, and scrolling with two fingers.

Please install ELAN touchpad and Intel graphic driver, these driver are not included in DVD bundled. You may download for drivers here. For Rp. 3.500.000, this notebook is a good choice.

How To: Create Good Password

Some rule of thumb creating password for your computer and or online account:
-Do not contain your username. Example your username is james.bond, your password should not contain that word, eg. jamesS3cre7.
-Do not contain any of your personal information, eg. your real name, place and or date of birth, your pet's name, your parent's name, etc. Its social engineering, easy to identify your self by people or things around you.
-Easy to remember but hard to be guessed. Your password should contain lowercase, uppercase, number and special character eg. !@#$%^. Example, Gl0b4lwaRminx.
-Change your password at least every three month.
-You should not use same password for your critical service account such as your Internet Banking, with other service such social network sites.

Free Push Email Software: Emoze

I'm using Emoze for my Nokia E63 push email service. You may use this cool application for free for personal use. Support multiple emails account, with Gmail, Yahoo!, H5 and Microsoft Live pre-configuration, you only need to provide username and password, and Emoze do the rest of set up process.

Windows XP Shortcut

Here its list of Windows XP shortcut. Note that this list is shortcut by Windows XP, not by specific application.

How To Activate Windows XP License Key

My Windows XP ask for activating, and worse, I don't have the license key. I found that this problem could be solved by editing registry entry.

C# free ebook

Are you looking for free C# ebook? Try download it for free here.

The Programmer's Heaven C# School book covers the .NET framework and the C# language. Starting with the basics of the language, it goes on to cover object oriented programming techniques and a wide range of C# languages features including interfaces, exceptions and delegates. Later chapters cover practical topics including database access with ADO.NET, building Windows forms applications, multi-threading and asynchronous I/O. The final chapter covers new features in C# 2.0, including generics.

TeraCopy: Speed-up your huge file copy

TeraCopy is designated to help end user copying their huge file, especially in copy/move to another computer, in faster way.
Simple interface

Integrated with Windows Explorer

TeraCopy will by-pass check file process before copy or move it, and do the process in parallel. Make copy/move file faster than native windows.

Compaq 515: Display Blank and Capslock Blinking

My friend's laptop Compaq 515 got problem: display blank and capslock key blinking. To solve this problem, unplug RAM, clean it carefully, then replug. If you install more than one module, try one-by-one on each slot, --usually there are two slots available-- until problem clear.

I hope you found it useful :).

Maintain Your Computer With CCleaner

CCleaner provides one stop solution for computer maintenance. It support Windows XP, Windows 7, windows Vista and Mac. Unlike its competitor, CCleaner has more features. Most of Windows maintenance software release their free software only with limited features such as registry cleaner, system start-up, cleaning browser chache etc. But CCleaner offers more advance features in free standard edition, some of them:

Windows Xp: Block Unwanted Website With DNS

I write about using Nawala DNS to protect our network/home computer from bad sites. We other option to accomplish this, by edit Windows XP DNS system directly. Open your Widows Explorer, go to C:\WINDOWS\system32\drivers\etc, open hosts file with notepad.

Acer ASPIRE 4750 Mousepad Can Not Tap

My friend's Acer Aspire 4750 with Windows XP installed get  problem: it's mousepad can't tap. Then I try to fix it, with action below:

Troubleshot Outlook Express: Send Email Report Failure

Microsoft Outlook Express has storage limitation. If Inbox size more than 2GB, Outlook Express will fail manage Sent Items file (email sent report will fail). We need to convert existing full Inbox folder in to archive folder.

IPMesenger: Chat And Transfer File On Your LAN

IPMesenger is a small (only 156 KB) yet useful program for chating and file transfer on Local Area Network. Its been around since 1997, even its web site and forum is 90's :). Available version for Windows XP and NIX* . You don't need any complex configuration. Just install it on each computer, start the program. Your friend's computer will appear. IPMesenger will display user name (user that is  logging in on remote computer) by default, but you can setting further if you need advance configuration.

Linux Di Virtualbox: Basic Firewall With IPTABLES

Quick cheat sheet common  IPTABLES function, I often forget, so I list here :).

To turn IPTABLES on every boot automaticaly: /sbin/chkconfig iptables on

To check status IPTABLES: iptables -L
To delete all parameters in IPTABLES: iptables -D

# Drop ICMP echo-request messages sent to broadcast or multicast addresses
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

# Drop source routed packets
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route

# Enable TCP SYN cookie protection from SYN floods
echo 1 > /proc/sys/net/ipv4/tcp_syncookies

# Reject ICMP redirect messages, system will not reply when get ping
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects

# Reject ICMP redirect messages
echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects

# Enable source address spoofing protection, any package that pretend from internal network will be rejected
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter

# Log packets with impossible source addresses
echo 1 > /proc/sys/net/ipv4/conf/all/log_martians

Hotmail: Automated Vacation Reply

I have been written about Hotmail's Sweeps feature. Now, you should try other useful feature: automation vacation replies.