Shutdown "no tty present and no askpass program specified"?
The error message appears when you try to run a command inside your bash call with sudo and, although the user ADMIN on the destination system mac123 has permissions to run commands with sudo, the option NOPASSWD is not specified for this particular user (in /etc/sudoers).

System would have to prompt user and wait for the password to be provided from the keyboard, however as no terminal is attached, the prompt would hang forever.

As a measure against such situation, system fails with the error message you got.



If you took time to understand my yesterday's answer:


  provided ADMIN has passwordless sudo permissions for shutdown or all commands on macxxx machine)


You wouldn't run into this problem.

You should modify your script:

...
if [ $DAYS_UP -ge ${MAX_UPDAYS} ];then
    echo Mac is going to shutdown 
    sudo shutdown -h now
else
...


And edit the sudoers file on mac123, so that it contains, for example (it must match the command in the script):

ADMIN ALL=(ALL) NOPASSWD: /sbin/shutdown -h now


Bear in mind that you must do it using visudo program, otherwise you will likely break your system completely.



Alternatively you can use SUDO_ASKPASS environment variable and point it to a script providing the password (the second part of the error message). I do not recommend this method.