Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Redirect output on script

Reply
Thread Tools

Redirect output on script

 
 
glenn.pringle@gmail.com
Guest
Posts: n/a
 
      09-17-2009
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
 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      09-17-2009
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
>

 
Reply With Quote
 
 
 
 
Michel Claveau - MVP
Guest
Posts: n/a
 
      09-17-2009
Hi!

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

@-salutations
--
Michel Claveau


 
Reply With Quote
 
Chris Rebert
Guest
Posts: n/a
 
      09-17-2009
On Thu, Sep 17, 2009 at 3:58 AM, (E-Mail Removed)
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
Response.redirect does not redirect from .aspx page =?Utf-8?B?VHJveQ==?= ASP .Net 3 10-15-2008 09:07 PM
How to fetch output of some other script in the current running perl script? ritugoyal12@gmail.com Perl Misc 4 10-27-2007 03:52 PM
Redirect to secure FTP site via response.redirect Ron Howard ASP General 2 08-11-2004 07:40 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM



Advertisments