Skip to main content

Posts

Showing posts from August, 2015

Linux : Detach command from Shell

So you have executed a command that is taking time, and you are fearing that if someone closes your shell program ( e.g. putty ), your command will stop?

Not to worry, do as intructed below:

1. Run command ( e.g. tar -xvf myfile.tar )
2. Press ctrl + z  ( This will pause the command )
3. Type "bg"  ( This will send the program to background )
4. Type " disown -h" ( This will  Detach command from Shell )

Now you can close your shell, but your command will remain running.


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Note : For checking, login on server with another shell, and grep your command:

ps -ef | grep tar

Python Script : Convert txt file to csv file

Dear Friends,

Some times you need to convert txt file to csv file automatically. Below is the code:

import csv

text1 = r"textfile.txt"
csv1 = r"csvfile.csv"

inputtxt = csv.reader(open(text1, "rb"), delimiter = '\t')
outputcsv = csv.writer(open(csv1, 'wb'))

outputcsv.writerows(inputtxt)


++++++++++++++++++++++++++++++++++++++++++

Note : csv package is available in python by default.