Script execution stops at os.execlpe()
<p>I am a bit of a newbie on Python, but was was testing some things I learned on Ubuntu.
Basically, this script is supposed to set your TCP/IP config, then restart the networking daemon and display the changes.</p>

<p>This is the whole script:</p>

<pre><code>#!/usr/bin/env python
import commands
import os
import sys

euid = os.geteuid()
if euid != 0:
    print "Script not started as root. Running sudo.."
    args = ['sudo', sys.executable] + sys.argv + [os.environ]
    # the next line replaces the currently-running process with the sudo
    os.execlpe('sudo', *args)

print 'Running. Your euid is', euid

print "IP"
IP = raw_input("&gt;&gt;")
print "Gateway"
PE = raw_input("&gt;&gt;")

ifconfig = commands.getoutput("ifconfig")
interfaz = ifconfig[0:5]

ArchivoInterfaces = open("/etc/network/interfaces", "w")
ArchivoInterfaces.write("#auto lo\n#iface lo inet loopback\nauto %s\niface %sinet static\naddress %s\ngateway %s\nnetmask 255.255.255.0"%(interfaz, interfaz, IP, PE))
ArchivoInterfaces.close()

ArchivoResolv = open("/etc/resolv.conf", "w")
ArchivoResolv.write("# Generated by NetworkManager\ndomain localdomain\nsearch localdomain\nnameserver 8.8.8.8\nnameserver 8.8.4.4")
ArchivoResolv.close()
os.execlpe('/etc/init.d/networking', "test","restart", os.environ)
print "Todo esta correcto, su IP ahora es %s" %(IP)
fin = raw_input("write d and press enter to show the changes, or press enter to exit.")

if fin == "d":
    ArchivoResolv = open("/etc/resolv.conf")
    ArchivoInterfaces = open("/etc/network/interfaces")
    ifconfig2 = commands.getoutput("ifconfig")
    print "ARCHIVO resolv.conf\n"+ArchivoResolv.read()+"\n\n"+"ARCHIVO interfaces\n"+ArchivoInterfaces.read()+"\n\n"+"RESULTADO DE \"ifconfig\"\n"+ifconfig2
    fin = raw_input("Presiona ENTER para salir.")
</code></pre>

<p>Unfortunately, it keeps stopping on this line - and I'm not sure why:</p>

<pre><code>os.execlpe('/etc/init.d/networking', "test","restart", os.environ)
</code></pre>

<p>After reaching this spot, the script runs the restart, and then just exits.</p>

<p>I would love to get it to run the last part of the script so I can see what changed, but I'm unable. Any ideas?</p>
