Re: test if shell is interactive

2012-01-22 Thread Bob Proulx
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

Re: test if shell is interactive

2012-01-22 Thread Chris F.A. Johnson
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

Re: test if shell is interactive

2012-01-22 Thread tapczan
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-

Re: test if shell is interactive

2012-01-22 Thread Bob Proulx
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

Re: test if shell is interactive

2012-01-22 Thread tapczan
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

Re: test if shell is interactive

2012-01-22 Thread DJ Mills
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?