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)?
--
View this message in context:
http://old.nabble.com/test-if-shell-is-
DJ Mills wrote:
>
> This is the correct way to test. What makes you say it's not working for
> you?
>
Variable $- value:
# echo $-
himBH
character 'i' meens is interactive, ok.
I have script a.sh:
#!/bin/bash
echo $-
Execution:
# ./a.sh
hB
There is no 'i' so the session is non-interactiv
Simple script a.sh:
#!/bin/bash
echo "PS1: $PS1"
Variable $PS1 is present:
# echo $PS1
\[\033[01;32m\]$USER@\h \[\033[00m\]\A \[\033[01;34m\]\w\[\033[00m\]\$
Variable $PS1 is environment:
# env | grep PS1
PS1=\[\033[01;32m\]$USER@\h \[\033[00m\]\A \[\033[01;34m\]\w\[\033[00m\]\$
Executing scri