This question is in a direct relation to this one: ssh fails to execute remote command when run from cron bash script – works from CLI
I'm not able to comment on the accepted answer as I don't have enough rep so please bear with me.
I'm running a script on a linux PC machine and the host i'm trying to get the output from is a router with its OS so it's nothing I can influence in terms of configuring the console.
Basically executing this under cron: OUT=$(ssh -tt -vv user@host.com "remote command")
gets me an empty variable.
debug1: Sending command: remote command
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 2621440 rmax 262144
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
If I'm executing this outside cron, i.e. in the CLI i'm getting output as expected.
As you can see the -tt option to force pseudo-tty allocation doesn't help.
Any solutions for this to help cron overcome the buggy remote console?
Best Answer
Your command print results stderr or stdout?
You can reroute
stderr
tostdout
using