scripting

Ash Wyllie ashw at myfairpoint.net
Thu Jan 19 21:58:03 UTC 2012


On Thu, 2012-01-19 at 17:40 +0000, Chris Green wrote:
> On Thu, Jan 19, 2012 at 12:30:14PM -0500, Ash Wyllie wrote:
> > I have a task that would be trivial on my old Amigas using Arexx. 
> > 
> > I have a folder with a bunch of 30 minute mp3s in it. I would like to
> > resample them and them split them in to 5 minute segments.
> > 
> > Soundconverter and mp3split can do the work, and python can find the
> > file names. 
> > 
> > But is there a way to have python call on external programs?
> > 
> There's several ways that Python can call external programs, in order of
> complexity/capability (all of these are in the Python os module) :-
> 
>     os.system(cmd)
>         Simple call of cmd, all you get back is the return code of cmd
> 
>     os.popen(cmd, mode='I', bufsize=-1)
>         Runs cmd and allows you to read its stdout (default mode 'I'),
>         or by changing mode to write to its stdin.
> 
>     os.popen2(), os.popen3(), os.popen4()
>         Similar to popen() but allow various combinations of stdin,
>         stdout and stderr to be read/written.
> 
>     os.execXX()
>         Several functions which use the system's underlying C functions
>         of the same names to run programs with various combinations of
>         arguments, environment etc.
> 
>  
Thanks, I didn't recognize the os.system() as what I wanted the first
time I saw it.

>    
> 
> -- 
> Chris Green
> 

-- 
                                            -ash
                                            Elect Cthulhu
                                            Vote the greatest evil





More information about the ubuntu-users mailing list