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: 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; '"': 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --089e0160b5e4130d3f04e40a9af2 Content-Type: text/plain; charset=ISO-8859-1 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 --089e0160b5e4130d3f04e40a9af2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


Hello =A0Friends ,

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

Case (a) :
=
The be= low code creates the =A0only one spare file named sp1 ,=A0

= =A0# Creating sparse files in the sparse path
=A0 =A0 =A0sparse_p= ath =3D os.path.join(path,'sparsefiles')
=A0 =A0 =A0os.ma= kedirs(sparse_path)
=A0 =A0 =A0os.chdir(sparse_path)
=A0 =A0 =A0sparsefiles =3D = "dd if=3D/dev/zero of=3Dsp1 count=3D0 bs=3D1 seek=3D10G"
=A0 =A0 =A0process_0 =3D subprocess.Popen(sparsefiles, stdout=3Dsubproces= s.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue)

Current output :
Sp1,

H= ow do I =A0loop my script to create 100 of files =A0like sp1 , sp2 ,sp3,.. = sp100 =A0.. using the same syntax
=A0" sparsefiles =3D "= ;dd if=3D/dev/zero of=3Dsp1 count=3D0 bs=3D1 seek=3D10G "=A0


Case (2) :

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

Example :
<= br>
# creat= ing sparse File
=A0sparse_path =3D os.path.join(path,'sparsefiles')
= =A0 =A0 =A0os.makedirs(sparse_path)
=A0 =A0 =A0os.chdir(sparse_pa= th)
=A0 =A0 =A0sparsefiles =3D "dd if=3D/dev/zero of=3Dsp1 c= ount=3D0 bs=3D1 seek=3D10G"
=A0 =A0 =A0process_0 =3D subprocess.Popen(sparsefiles, stdout=3Dsubpro= cess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue)

=A0 =A0 # Creating Regular files
=A0 =A0 =A0Regular_path =3D os.= path.join(path,'regularfiles')
=A0 =A0 =A0os.makedirs(Regular_path)
=A0 =A0 =A0os.chdir(Reg= ular_path)
=A0 =A0 =A0regularfiles =3D " dd if=3D/dev/urando= m of=3Dfile1 count=3D0 bs=3D1 seek=3D10"
=A0 =A0 =A0process_= 1 =3D subprocess.Popen(regularfiles, stdout=3Dsubprocess.PIPE, stderr=3Dsub= process.PIPE, shell=3DTrue)


M= y goal is to create various kinds of files like sparse, regular ,directorie= s, hard and symlinks etc=A0
what would be th= e best way to do achieve this ?

Regards,
Ga= nesh
--089e0160b5e4130d3f04e40a9af2--