Read commands from an input file. Usage: source
( self, line )
| 345 | quietRun( 'stty echo' ) |
| 346 | |
| 347 | def do_source( self, line ): |
| 348 | """Read commands from an input file. |
| 349 | Usage: source <file>""" |
| 350 | args = line.split() |
| 351 | if len(args) != 1: |
| 352 | error( 'usage: source <file>\n' ) |
| 353 | return |
| 354 | try: |
| 355 | with open( args[ 0 ] ) as self.inputFile: |
| 356 | while True: |
| 357 | line = self.inputFile.readline() |
| 358 | if len( line ) > 0: |
| 359 | self.onecmd( line ) |
| 360 | else: |
| 361 | break |
| 362 | except IOError: |
| 363 | error( 'error reading file %s\n' % args[ 0 ] ) |
| 364 | self.inputFile.close() |
| 365 | self.inputFile = None |
| 366 | |
| 367 | def do_dpctl( self, line ): |
| 368 | """Run dpctl (or ovs-ofctl) command on all switches. |