Python: Creating upm profile with script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎01-04-2017 03:09 PM
I'm trying to write a python script to configure new switches and right now I'm struggling with creating UPM profiles through the script as running create upm profile [profilename] opens an interactive session, are there ways to make the python interpreter direct its output into this session or alternatively other ways to creating / editing upm profiles without calling this interactive session?
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎01-04-2017 06:47 PM
You could use a subprocess shell to send commands that need CLI interaction:
This example creates a upm profile named 'test':
import subprocess
p = subprocess.Popen(['/exos/bin/exsh','-n0', '-b', '-e','remote_serial'],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
print >> p.stdin, 'create upm profile test'
print >> p.stdin, '.'
This example creates a upm profile named 'test':
import subprocess
p = subprocess.Popen(['/exos/bin/exsh','-n0', '-b', '-e','remote_serial'],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
print >> p.stdin, 'create upm profile test'
print >> p.stdin, '.'
