Bad Character code (256)/ \select@language{greek}

(Too long for a comment). It is a babel bug. It relies on a temporary counter and fails when listings sets it to 256:

\documentclass{book}

\usepackage[english,greek]{babel}

\begin{document}
\makeatletter
\@tempcnta=256
\selectlanguage{greek}

\end{document}

Sent a bug report to the babel maintainer or the babel-greek maintainer.


UPDATE

The problem has been fixed with babel-greek version 1.9e, released on 2015/11/27

Original answer

Here's a temporary fix, that should work if Greek is the last language loaded; it just restores the value of \@tempcnta to what it would be if listings is not loaded. However, this is a bug in babel-greek: no package should rely on any particular value of \@tempcnta; my impression is that some code has been added that is useless.

\documentclass{article}
\usepackage[greek]{babel}
\usepackage{listings}

\makeatletter
\AtBeginDocument{%
  \expandafter\def\expandafter\originalTeX\expandafter{%
    \expandafter\@tempcnta\number253\expandafter\relax\originalTeX}%
}
\makeatother

\begin{document}
a
\end{document}

The bad code is in line 376 of greek.ldf that says

376       \babel@savevariable{\lccode\@tempcnta}\lccode\@tempcnta=\@tempcnta

while it should be

376       \expandafter\babel@savevariable\expandafter{\expandafter\lccode\the\@tempcnta}\lccode\@tempcnta=\@tempcnta

so the correct instructions

\babel@savevariable{\lccode128}
\babel@savevariable{\lccode129}
...
\babel@savevariable{\lccode252}

are executed instead of doing several times the useless (and wrong)

\babel@savevariable{\lccode\@tempcnta}

Thus a better temporary fix would be

\documentclass{article}
\usepackage[greek]{babel}
\usepackage{listings}

\makeatletter
% Avoid the spurious error
\AtBeginDocument{%
  \expandafter\def\expandafter\originalTeX\expandafter{%
    \expandafter\@tempcnta\number253\expandafter\relax\originalTeX}%
}
% apply the fix
\addto\extrasgreek{%
  \@tempcnta=128
  \@whilenum\@tempcnta<253\do{%
    \expandafter\babel@savevariable\expandafter{\expandafter\lccode\the\@tempcnta}%
    \lccode\@tempcnta=\@tempcnta
    \advance\@tempcnta\@ne
  }%
}
\makeatother
\begin{document}
a
b
\end{document}