How to I do this in Python ?
Roy Smith
roy at panix.com
Fri Aug 16 07:47:08 EDT 2013
In article <mailman.614.1376636762.1251.python-list at python.org>,
Ganesh Pal <ganesh1pal at gmail.com> wrote:
> # Creating sparse files in the sparse path
> sparse_path = os.path.join(path,'sparsefiles')
> os.makedirs(sparse_path)
> os.chdir(sparse_path)
> sparsefiles = "dd if=/dev/zero of=sp1 count=0 bs=1 seek=10G"
> process_0 = subprocess.Popen(sparsefiles, stdout=subprocess.PIPE,
> stderr=subprocess.PIPE, shell=True)
There is no need to shell out to dd just to do this. All dd is doing
for you is seeking to the offset you specify and closing the file. You
can do that entirely in Python code.
http://docs.python.org/2.7/library/stdtypes.html#file.seek
More information about the Python-list
mailing list