I'm trying to write the output (error or success) to a file. With other commands I can do this without issue however the below commands will only write to the terminal but not to a file. If I run directly in the terminal I can see the output on the screen and the file's will be created but will be empty.
The commands are
sudo ip r add default via 192.168.1.254 > outfile.txt >&1 sudo ip r add default via 192.168.1.254 | tee -a outfile.txt sudo /sbin/route add default gw 192.168.1.254 | sudo tee -a outfile.txt
These are going in a boot script (headless setup). I'm not able to simulate the boot conditions from within the terminal directly so just running them directly doesn't necessarily give me the output that happens in boot conditions meaning I can't work out why/whats causing them to fail.
The output when I run directly in the terminal is
RTNETLINK answers: Network is unreachable for
sudo ip r add default via 192.168.1.254
SIOCADDRT: Network is unreachable for
sudo route add default gw 192.168.1.254which is expected in those conditions