I understand it is extremely rare and the concept, but can't think of a use for it. I do have an idea that we may want to execute a script that has a command to login to a server through ssh, is that something that needs to be done at times and is it an example of where a non-interactive login shell is useful?
Asked
Active
Viewed 794 times
1 Answers
5
Study the Unix way commands are run: the existing (login) shell is forked (duplicated), and the command is execed. If the forked shell runs another shell, that shell is non-interactive. Type in the command"
$ echo "$- 'i' indicates interactive"
himBHs 'i' indicates interactive
Now put the above line in a file (foo) and run
bash foo
hB 'i' indicates interactive
No "i", so being run in a non interactive shell. Make foo executable and try again"
chmod +x foo
./foo
hB 'i' indicates interactive
Again no "i" Unless you force things with:
bash -i foo
himBH 'i' indicates interactive
Then you again see the "i"
ubfan1
- 19,049