[Tutor] File copying - best way?

lumbricus@gmx.net lumbricus@gmx.net
Mon, 6 Aug 2001 00:12:09 +0200


On Sun, Aug 05, 2001 at 10:46:55PM +0100, alan.gauld@bt.com wrote:
> 
> > "errno" useful also
> > - but I have no clue how to use it.  Would this have allowed 
> > me to test:
> > 
> > os.popen("ls *.jpg")
> > 
> > if it found no jpg files?
> 
> No. The reason being that in Unix 'ls' findng no files is 
> NOT an error. 

Hmm...
$ cd /etc
$ ls
[snip]
$ echo "$?"
0
$ ls ./*.jpg
ls: ./*.jpg: Datei oder Verzeichnis nicht gefunden
$ echo "$?"
1
$

It sets errno on my System

$ uname -a
Linux Laplace.localdomain 2.2.19 #1 Sam Apr 21 17:18:27 CEST 2001 i586 unknown

'ls' simply reports, quite accurately, the contents 
> of a directory, if it's empty 'ls' returns am empty list! That's 
> not an error. 'ls' will return an error if you ask it to list 
> the contents of a non existent directory however.
> 
> In that case the errno() stuff might be useful to you...
> 
> Alan g
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 
When it is not necessary to make a decision, it is necessary not to
make a decision.