Python reference

Heiko Wundram heikowu at ceosg.de
Thu Jun 3 16:23:12 EDT 2004


Am Donnerstag, 3. Juni 2004 21:55 schrieb Reiner Block:
> -----------------------------------------------------------------------
> import os
> os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')
> -----------------------------------------------------------------------

First and second parameter are clear to you, you say. Okay, let's start from 
there: third parameter is the first parameter the program gets to see. What 
is the first parameter of a program (sys.argv[0])? That's the program name! 
Fourth parameter, and fifth should be clear, anyhow.

Try this:

os.spawnlp(os.P_WAIT,'cp','gugu','nonexistant','neitherexistant')

The output you'll see on the console is:

gugu: Aufruf von stat für ,,nonexistant" nicht möglich: Datei oder Verzeichnis 
nicht gefunden

So, cp does as it should, the program name which is output (in case you called 
a symlink or something, it can reference you to the symlink, and doesn't 
always print cp) is the first parameter to the program we passed in.

HTH!

Heiko.




More information about the Python-list mailing list