Adding some config to a juniper device
The confirmation prompt is a self-contained chunk of code with a specific purpose.  It deserves to be extracted into a function:

def confirm(prompt='Y or N: ', yes='YES', no='NO'):
    while True:
        response = raw_input(prompt).upper()
        if yes.startswith(response) and not no.startswith(response):
            return True
        elif no.startswith(response) and not yes.startswith(response):
            return False
        print "Invalid choice. Try again."


(Technically, this is more lenient than your original code, in that it accepts strings like 'yE' as a yes.  I think that's OK.)

Then, in your main program, you can write:

print "Do you want to continue to run these commands?"
if not confirm():
    print "Exiting..."
    quit()




Any call to open() should almost certainly be done using a with block.  You wrote with open('switchlist') as infile, which is good.  However, you also wrote commands = open("commands", "r") and incmd = open('commands'), neither of which you close properly.  But why are you calling incmd = open('commands') at all, when it's just supposed to be commands_to_commit?