tapczan wrote:
> Bob Proulx wrote:
> > Shell scripts are not interactive.  So what you are seeing above is
> > correct.
> 
> So, is there any way to test if script (a.sh) was invoked from interactive
> session (human) or not (e.g. from cron)?

I usually check if the standard input file descriptor is attached to a
tty device or not.

  #!/bin/sh
  if [ -t 0 ]; then
    echo has a tty
  else
    echo does not have a tty
  fi
  exit 0

Or something like:

  $ test -t 0 && echo yes tty || echo no tty

Note: This discussion thread is much better suited for help-bash since
it isn't talking about a bug in bash.  In the future if you are just
asking questions that would be the better list to send them to.

Bob

Reply via email to