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 i
On Sun, 22 Jan 2012, 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)?
Test whether it is attached to a tty:
if
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-
tapczan wrote:
> #!/bin/bash
> echo $-
>
> Execution:
>
> # ./a.sh
> hB
>
> There is no 'i' so the session is non-interactive?
> It was invoked from interactive.
> Am I missing something?
Shell scripts are not interactive. So what you are seeing above is
correct.
Bob
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
On Sun, Jan 22, 2012 at 9:39 AM, tapczan wrote:
> 1.
> case "$-" in
> *i*) echo This shell is interactive ;;
> *) echo This shell is not interactive ;;
> esac
>
This is the correct way to test. What makes you say it's not working for you?