You are not logged in.

#1 2012-05-03 02:48:31

Bellum
Member
Registered: 2011-08-24
Posts: 230

[solved] python execvp

I'm writing a script that will select a new wallpaper periodically like in Windows 7. Running into some trouble, though.

def setbg(images):
	imgnum = random.randint(0, len(images))
	command = ['-fill', images[imgnum] ]
	#print(command[0] + ' ' + command[1])
	execvp('hsetroot', command)

I keep getting hsetroot's usage screen. I'm not sure why; when I print out the args they look correct to me.

Last edited by Bellum (2012-05-03 04:24:13)

Offline

#2 2012-05-03 03:44:28

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: [solved] python execvp

You need to provide a dummy first parameter.

Try:

command = ['', '-fill', images[imgnum] ]
execvp('hsetroot', command)

Offline

#3 2012-05-03 04:23:49

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: [solved] python execvp

Ah, thanks, that worked correctly. Then I immediately discovered that of course execvp does not return. tongue

subprocess.call was what I was looking for. Incidentally, I've got to say pythons documentation is great. I don't even really know python , but I was able to churn out this script in no time.

Offline

Board footer

Powered by FluxBB