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

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
o 'i' so the session is non-interactive? It was invoked from interactive. Am I missing something? I tested on vanilla debian 6.0, ubuntu 11.10 - effect is the same. -- View this message in context: http://old.nabble.com/test-if-shell-is-interactive-tp33183345p33184499.html Sent from the Gnu - Bash mailing list archive at Nabble.com.

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?

test if shell is interactive

2012-01-22 Thread tapczan
Executing script: # ./a.sh PS1: Variable PS1 is empty in child process. Whether the enviroment variable should not be copied to the child process? Am I doing something wrong? Popular methods to test if shell is interactive or not don't work for me: 1. case "$-" in *i*)echo