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 400 times
5
1 Answers
3
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
- 17,838
cron,at,batchjobs, among other tasks. "Non-interactive" means the process doesn't have a human (orexpect) attached. – waltinator Dec 11 '23 at 18:11/etc/profile, etc. and set environment variables and such from there) - that's to say, during that time, non-interactive login shells were incredibly common, if unnoticed. Now GDM is the default and GDM doesn't do that. – muru Dec 12 '23 at 04:47