I've just installed the 'mail' command in Ubuntu (mailutils package) in order toview feedback from cron jobs.I type 'mail' at the prompt and see something like this:/var/mail/*$USER*: 1 message 1 unread>U 1 *Name* *Date* Output from your job I type 1 at the ? prompt and get a lot of output about the message (From, Date, Subject...) but on the last line it saysError: Can't open display:?and I'm returned to the prompt.Does anyone have any idea what the problem might be?
Linux 'mail' command: Can't open display
bash;ubuntu;cron;email
The mail program opens emails in a pager. The environment variable PAGER can override the default pager, which is typically less. In Debian-based systems, there is a /usr/bin/pager that is managed by the alternatives system. You need to ensure that your pager is not a GUI application, which would require X. An easy way to test this is to set PAGER temporarily.PAGER=/usr/bin/less mail