2

I have a script that configures a Juniper router to my companies specifications. Nothing overly fancy it just follows the procedures they gave me. And reads in whatever file configuration is in a specified folder. Anyhow, the very last step in the procedure is to his Ctrl + D for end of transmission. Strangely, this problem seems to be unique to me, ^C and ^V seem to be common characters, but not ^D. I have tried /EOT. Does anyone know how this simple script would go about sending ^D? The code hangs on /EOT, which is why I'm guessing that I'm not expressing that character right.

   ser.write ('root\r\n') 
    time.sleep(5)
    ser.write ('cli\r\n')
    ser.write('configure\r\n')  
    ser.write('top\r\n')
    ser.write('load set terminal\r\n')
    file = open('REDACTED', 'r+')
    text = file.read()
    ser.write(text + '/r')
    ser.write('\n')
    ser.write('\EOT')
    ser.write('commit and-quit\r\n')

`

1 Answer 1

2

The escape sequence '\EOT' does not exist.

In order to send ASCII code 0x04 (EOT) use following command:

ser.write( b'\x04' );   # send ^D (EOT)

See also PySerial: How to send Ctrl-C command on the serial line

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.