Converting a Shell Script to run under Python

Magnus L. Hetland mlh at vier.idi.ntnu.no
Tue Dec 7 09:53:39 EST 1999


"Austin Wilson" <wilson.austin.aj at bhp.com.au> writes:

> Thanks.  That worked beautifully.

:)

You should check out the library reference at www.python.org, and look
into the os module.

> 
> What is the command for copying file1 to file3 (eg equivalent to cp file1
> file3)

How strange... I can't seem to find any intelligent command for this.
Hm. You could of course read it all in and then write it out again, as
in

open("file3","w").write(open("file1").read())

though that is probably not a good idea. I guess I would rather do

os.system("cp file1 file2")

although that seems like cheating... ;)

> and creating a soft link to a file (eg ln -s file2 file1)?

os.symlink("file2","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