First, note the following in the documentation for ps-spool-buffer-with-faces:
This command works only if you are using
a window system, so it has a way to determine color values.
If you use --batch or run on a terminal, then there isn't a window system available as
far as emacs can tell. Try "emacs --batch --eval='(message window-system)'" to
see.
Next, emacs does a *lot* of things to start up, and the environment might not
always be good for doing programming kinds of things on the command line.
For example, it's only in step 23 that a buffer is guaranteed to be selected,
and that is /after/ it has handled the command line arguments (step 21). See
the info for '(elisp) Startup Summary'.
To do anything sophisticated, you should probably really be doing it in lisp
where you have real control. Even using --eval '(sample code)' on the command
line would probably be more reliable. If you want to use emacs to support shell
programming, then maybe starting it --daemon and using emacsclient is the way
to go. (On the other hand, you would then affect your whole environment and
that might complicate other things.)