-1

I copied some code from http://wiki.dovecot.org/PostLoginScripting and made the following bash script "dovecot_postlogin.sh" :

if [ "$USER" = "myuser" ] ; then
    printf "* NO [ALERT] The user '$USER' can not login\r\n"
    exit 0
fi
exec "$@"

but keep getting

"dovecot: imap-postlogin: Error: /usr/local/bin/dovecot_postlogin.sh: 6: /usr/local/bin/dovecot_postlogin.sh: Syntax error: end of file unexpected (expecting "then")" 

in my mail.log.

Michal M.
  • 1
  • 1
  • The error message says the error is on line 6. Are you showing the complete script? – Kusalananda Aug 04 '16 at 13:56
  • yes line 6 is a blank line but it wont show within the code tag here on the site – Michal M. Aug 04 '16 at 13:57
  • The error message suggests an `if` without a `then` on a previous line; or possibly, you have invisible but significant whitespace which you will not have been able to paste correctly here. I'm afraid your question, as it stands now, is off-topic for being unreproducible; but do feel free to [edit] it to include a [mcve]. – tripleee Aug 04 '16 at 14:06
  • The error message vaguely suggests that the script may not be executed by `sh`. Does it have a valid `#!/bin/sh` shebang line? – tripleee Aug 04 '16 at 14:08

1 Answers1

0

Thanks a lot for your suggestions! I have created a new file over SSH and rewritten (typed by hand) the code with nano editor on my linux system and now it works. I have edited the file previously with the Atom editor over a SSHFS Manager.

Michal M.
  • 1
  • 1