- Local script in operation mode:Here is an example:
vyatta@vyatta:~$ cat test1.sh
#!/bin/bash
run=/opt/vyatta/bin/vyatta-op-cmd-wrapper
$run show configuration > /tmp/vyatta-running
$sudo scp /tmp/vyatta-running root@syslog.example.com:/root/ (requires public-key authentication of vyatta in syslog server) - Local script in configuration modeHere is an example:
vyatta@vyatta:~$ nano test2.sh
#!/usr/bin/expect
#set timeout 1
spawn $env(SHELL)
send “configure\r”
expect -re “.*# $”
sleep 5
send “save /home/vyatta/running-config\r”
expect -re “.*# $”
send “exit\r”
exit
expect eofIn VyOS there are more efficient ways for scripting in configuration mode.
- Remote script in operational mode:[root@syslog ~]# ssh -p 8xxx vyatta@208.x.x.x < test1.sh (requires public-key authentication of syslog in vyatta)
[root@syslog ~]# cat test1.sh
#!/bin/bash
run=/opt/vyatta/bin/vyatta-op-cmd-wrapper
$run show configuration > /tmp/vyatta-running
$sudo scp /tmp/vyatta-running root@syslog.example.com:/root/
- We have not been able to find a solution for running remote script in configuration mode. This should be possible in VyOS. A workaround is to create a local script in configuration mode along with another script for remote execution. ( See the Vyatta running-config backup scripts)