Redirect output on script

2009-09-17 Thread glenn.prin...@gmail.com
I would like to redirect the output of the command below to another
file
type test.txt  test.bak

I'm trying to do this as part of a python script running on Windows
XP.

I'm using os.system('type filepath.txt  filepath.bak') but nothing
is happening.

I was wondering if somebody could enlighten me.



Thanks,


Glenn Pringle
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Redirect output on script

2009-09-17 Thread MRAB

glenn.prin...@gmail.com wrote:

I would like to redirect the output of the command below to another
file
type test.txt  test.bak

I'm trying to do this as part of a python script running on Windows
XP.

I'm using os.system('type filepath.txt  filepath.bak') but nothing
is happening.


Try:

os.system('type filepath.txt  filepath.bak')

or just:

os.system('type filepath.txt  filepath.bak')


I was wondering if somebody could enlighten me.


--
http://mail.python.org/mailman/listinfo/python-list


Re: Redirect output on script

2009-09-17 Thread Michel Claveau - MVP
Hi!

import os
os.system('cmd /c type L:\\source.fic L:\\destination.txt')

@-salutations
-- 
Michel Claveau


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Redirect output on script

2009-09-17 Thread Chris Rebert
On Thu, Sep 17, 2009 at 3:58 AM, glenn.prin...@gmail.com
glenn.prin...@gmail.com wrote:
 I would like to redirect the output of the command below to another
 file
 type test.txt  test.bak

 I'm trying to do this as part of a python script running on Windows
 XP.

 I'm using os.system('type filepath.txt  filepath.bak') but nothing
 is happening.

 I was wondering if somebody could enlighten me.

Using the handy-dandy subprocess module:

bak = file('filepath.bak', 'w')
subprocess.call(['type', 'filepath.txt'], stdout=bak)

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list