[Tutor] Read a file text and write on another one !

Borgulya Gabor borgulya@pons.sote.hu
Thu, 18 May 2000 17:10:21 +0200 (CEST)


On Thu, 18 May 2000, Khalid MOULFI wrote:
> file = open('t1.txt','r')
> os.system('ls -al ' + file)
> 
> I had when I launched it the following outputs :
> 
> <closed file '/test/koko.startup', mode 'w' at 20095078>
> Traceback (innermost last):
>   File "ex3.py", line 25, in ?
>   	cmd = 'ls -al ' + file
> TypeError: illegal argument type for built-in operation

The following code should work (although there is shurely a better
solution):

filename='t1.txt'
os.system('ls -al ' + filename + ' > ls_output.txt')
file = open('ls_output.txt','r')

Gabor