Custom Search

Tuesday, April 30, 2013

How to recover a corrupted tar.gz file in ubuntu

How to recover a corrupted tar.gz file in ubuntu

1) Insatall gzrt
#sudo apt-get install gzrt

2)Recover corrupted tar.gz file
#gzrecover my-corrupted-backup.tar.gz
This command will create a *.recovered file



3) Extract corrupted tar.gz file
#cpio -F my-corrupted-backup.tar.recovered -i -v
This command will extract files from corrupted tar.gz

cpio --> Copy file from archives
-F --> Read File
-i --> copy-in operation
-v --> lists file names as they are extracted

How to upgrade Ubuntu 12.04 to 13.04

How to upgrade Ubuntu 12.04 to 13.04

1)
First Download Ubuntu 13.04 iso


2)
Boot from Ubuntu 13.04 iso

3)
Select Option "Upgrade Ubuntu 12.04 to 13.04" and continue

How to upgrade Ubuntu 12.04 to 13.04 using iso image

How to upgrade Ubuntu 12.04 to 13.04 using iso image

1)
First Download Ubuntu 13.04 iso


2)
Boot from Ubuntu 13.04 iso

3)
Select Option "Upgrade Ubuntu 12.04 to 13.04" and continue

Monday, April 29, 2013

How to search for a module in python package repository

How to search for a module in python package repository using pip

#pip search mysql

#pip search boto

#pip search sqlalchemy


#pip search netaddr

#pip search turbogears

#pip search simplejson

How to search for a file in tar.gz file in Ubuntu

How to search for a file in tar.gz file in Ubuntu
#tar -tzvf data.tar.gz | grep filename

How to list all files in a tar.gz file in ubuntu

How to list all files in a tar.gz file in Ubuntu

To view a detailed table of contents (list all files) in a tar file
#tar -tzvf data.tar.gz

How to extract tar.gz file in Ubuntu

How to extract tar.gz file in Ubuntu

1)
Extract tar file into current directory.

#tar -zxvf data.tar.gz


2)
Extract tar file into different directory.

#tar -zxvf data.tar.gz -C /home/saju/dest_dir

How to create tar.gz file in ubuntu

How to create tar.gz file in Ubuntu

a) Create a tar.gz file including all files in the current directory
#tar -czvf data.tar.gz *

b) Create a tar.gz file including all files in the directory data_dir
#tar -czvf data.tar.gz data_dir


c) Create a tar.gz file including files data_file1 and data_file2
#tar -czvf data.tar.gz data_file1 data_file2

Friday, April 12, 2013

How to convert jpg to tiff for OCR with tesseract

1)
Install PIL
#pip install pil

2)
Install  tesseract-ocr
#sudo apt-get install tesseract-ocr

3)
Install  pytesser
http://code.google.com/p/pytesser/downloads/detail?name=pytesser_v0.0.1.zip&can=2&q=
4)
Convert your image to tif
#convert myimage.jpeg -auto-level -compress none myimage.tif

 
5)
Python code to read data from myimage.tif

from PIL import Image
from pytesser.pytesser import *

image_file = 'myimage.tif'
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print "=====output=======\n"
print text