Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52581

How to I do this in Python ?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ganesh1pal@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'newbie': 0.05; 'output': 0.05; 'subject:Python': 0.06; 'sub': 0.09; 'subject:How': 0.10; 'python': 0.11; 'creates': 0.14; 'subject: ?': 0.16; 'module': 0.19; 'command': 0.22; 'example': 0.22; 'creating': 0.23; '(a)': 0.24; 'skip:\xa0 20': 0.24; 'script': 0.25; 'shown': 0.26; '8bit%:3': 0.30; 'specified': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; '&quot;': 0.31; 'file': 0.32; 'regular': 0.32; 'running': 0.33; 'basic': 0.35; 'skip:s 30': 0.35; '(2)': 0.35; 'etc': 0.35; 'received:google.com': 0.35; 'there': 0.35; '8bit%:9': 0.36; 'skip:o 20': 0.38; 'problems': 0.38; '8bit%:4': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'skip:o 30': 0.61; 'great': 0.65; 'goal': 0.75; '100': 0.79; 'friends': 0.81; 'subject:this': 0.83
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=b+OXzosxt0bRWMRF4IViA/UwMSf7FolOJYvNN69eN7c=; b=k8+tZkvCTLtDDOF/ANIqRmAOIhZxnE0QJUUCccGYvwYBsVsHRX1uk4Nlj8zGzbiXnz mEahMel5dfVniJo/8IYt2lgZdNnvs+H7dDVWjrJAcOmUkkC9aucLHyel4b2t+LBkcEWh hg/VkXvNaG/Nek4GJmlNsRfHVuQvMtEJgDLu3GMfgzvCM7e33iSqQzh5Cvo/0a+2mfLD s6hkhhfAKNUX+vcpzWv/2q2iZvw4+dRIsg9ZIjTkXp9VR3mNMpPXfsbxs/Oa+hao9B/T TlFoYgcXQxnGUgx/9aGuKiPCa1Gy05W+nCJKFPCUGyhULggqiaIb16H8WdcmdkVpFxQu D+1g==
MIME-Version 1.0
X-Received by 10.152.37.103 with SMTP id x7mr1000887laj.28.1376634092586; Thu, 15 Aug 2013 23:21:32 -0700 (PDT)
Date Fri, 16 Aug 2013 11:51:32 +0530
Subject How to I do this in Python ?
From Ganesh Pal <ganesh1pal@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=089e0160b5e4130d3f04e40a9af2
X-Mailman-Approved-At Fri, 16 Aug 2013 09:06:01 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.614.1376636762.1251.python-list@python.org> (permalink)
Lines 134
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376636762 news.xs4all.nl 15965 [2001:888:2000:d::a6]:39813
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52581

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello  Friends ,

Iam a newbie to python , Iam writing a small script that would generate
various kinds of files
in the specified path . Iam using sub process module to achieve this , I
have stuck with few basic problems , any help on this would be great

Case (a) :

The below code creates the  only one spare file named sp1 ,

 # 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)

Current output :
Sp1,

How do I  loop my script to create 100 of files  like sp1 , sp2 ,sp3,..
sp100  .. using the same syntax
 " sparsefiles = "dd if=/dev/zero of=sp1 count=0 bs=1 seek=10G "


Case (2) :

Is there a better way to create the files in Python other than using  sub
process module and running dd command as shown below ..

Example :

# creating sparse File
 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)

    # Creating Regular files
     Regular_path = os.path.join(path,'regularfiles')
     os.makedirs(Regular_path)
     os.chdir(Regular_path)
     regularfiles = " dd if=/dev/urandom of=file1 count=0 bs=1 seek=10"
     process_1 = subprocess.Popen(regularfiles, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)


My goal is to create various kinds of files like sparse, regular
,directories, hard and symlinks etc
what would be the best way to do achieve this ?

Regards,
Ganesh

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How to I do this in Python ? Ganesh Pal <ganesh1pal@gmail.com> - 2013-08-16 11:51 +0530
  Re: How to I do this in Python ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-16 10:59 +0000
    Re: How to I do this in Python ? Ganesh Pal <ganesh1pal@gmail.com> - 2013-08-18 22:36 +0530
      Re: How to I do this in Python ? Steven D'Aprano <steve@pearwood.info> - 2013-08-19 07:27 +0000
        Re: How to I do this in Python ? Ganesh Pal <ganesh1pal@gmail.com> - 2013-08-28 10:10 +0530
  Re: How to I do this in Python ? Roy Smith <roy@panix.com> - 2013-08-16 07:47 -0400
    Re: How to I do this in Python ? random832@fastmail.us - 2013-08-16 14:17 -0400

csiph-web