MacOS – How to tell Mac OS Messages.app to go online from the command line

automationcommand linemacosmessages

I observed that quite often some accounts on Messages.app (Mac OS Sierra) may become offline and I want to automate the reconnection when I connect to VPN.

So, the question is: what command line commands should I run in order to start Messages.app and restore connections. Note: Messages.app may already be opened but my account may be offline.

Best Answer

Here is the command for terminal:

osascript -e 'tell application "Messages" to log in'