Converting a Shell Script to run under Python

Austin Wilson wilson.austin.aj at bhp.com.au
Tue Dec 7 00:38:37 EST 1999


Thanks.  That worked beautifully.

What is the command for copying file1 to file3 (eg equivalent to cp file1
file3) and creating a soft link to a file (eg ln -s file2 file1)?

Thanks
Austin

Magnus L. Hetland <mlh at vier.idi.ntnu.no> wrote in message
news:y0jhfhva9p5.fsf at vier.idi.ntnu.no...
> "Austin Wilson" <wilson.austin.aj at bhp.com.au> writes:
>
> > Hi
> >
> > I was hoping someone may be able to help me convert the following Shell
> > Script to perform the same functions under python. Basically it just
reads a
> > filename which is stored in file1 and then renames file2 to that name.
>
> I suspect you'll get several responses in parallel here, but that's
> just the spirit of c.l.p :)
>
> >
> > #!/bin/sh
> > read name < file1
> > mv file2 $name
> > rm file1
>
> #!/usr/bin/env python
> import os
> name = open("file1").read()
> os.rename("file2",name)
> os.remove("file1")
>
> (Remember not to put a newline character after the filename in
> file1... :)
>
> >
> > Thanks
> > Austin
> >
>
> --
>
>   Magnus          Echelon jamming noise:
>   Lie             FBI CIA NSA Handgun Assault Bomb Drug Terrorism
>   Hetland         Special Forces Delta Force AK47 Hillary Clinton




More information about the Python-list mailing list