Summary: When running “show interfaces” via script, it outputs properly when run as my regular user, but not as root
, which is what Task Scheduler runs as.
I’ve confirmed this works properly on 1.2.5 (lts built via docker), but not on the latest 1.3-rolling.
Script:
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
echo $(date) >> /config/scripts/log-shInterfaces.log
echo $(id) >> /config/scripts/log-shInterfaces.log
echo $(run show interfaces) >> /config/scripts/log-shInterfaces.log
Output when run via bash
in the CLI:
ryanb@vyos:~$ tail -f /config/scripts/log-shInterfaces.log
Sat 18 Jul 2020 09:34:27 AM CDT
uid=1004(ryanb) gid=100(users) groups=100(users),4(adm),6(disk),27(sudo),30(dip),105(vyattacfg),116(frrvty)
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down Interface IP Address S/L Description --------- ---------- --- ----------- eth0 10.1.0.6/30 u/u Uplink to ubnt01-edge eth1 10.1.0.13/29 u/u LAN 2001:470:c28c::2/127 lo 127.0.0.1/8 u/u ::1/128 tun0 [redacted]/64 u/u HE.NET IPv6 Tunnel vti0 192.168.0.0/32 u/u VPN Tunnel to Azure01 vti1 192.168.0.1/32 u/u VPN Tunnel to Azure02 wg0 10.1.254.1/24 u/u [redacted]/64 wg2 192.168.1.2/32 u/u wg3 192.168.1.3/32 u/u wg4 192.168.1.4/32 u/u
Output when run via task-scheduler:
ryanb@vyos:~$ tail -f /config/scripts/log-shInterfaces.log
Sat 18 Jul 2020 09:38:01 AM CDT
uid=0(root) gid=105(vyattacfg) groups=105(vyattacfg),0(root)
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down Interface IP Address S/L Description --------- ---------- --- -----------
Task scheduler config commands, if it matters:
set system task-scheduler task test executable path /config/scripts/shInterfaces.sh
set system task-scheduler task test interval 1m
Version info:
Version: VyOS 1.3-rolling-202007060117
Release Train: equuleus
Built by: autobuild@vyos.net
Built on: Mon 06 Jul 2020 01:17 UTC
Build UUID: 2b4439cd-6836-4397-b011-9fd100208a18
Build Commit ID: c7b0a8897cfa85
Architecture: x86_64
Boot via: installed image
System type: VMware guest
Hardware vendor: VMware, Inc.
Hardware model: VMware Virtual Platform
Hardware S/N: Unknown
Hardware UUID: Unknown
Copyright: VyOS maintainers and contributors