Linked Questions

1
vote
1answer
2k views

How do I tell whether I'm in a non-login shell or a login shell? [duplicate]

Possible Duplicate: How to check if a shell is login/interactive/batch And what's the benefits of non-login shell over login shell?
0
votes
1answer
2k views

Can I use an if statement to detect if bash and dash are being run interactively? [duplicate]

After looking around for a while I've found several good pages describing how to check and see if a bash script is running interactively and there seem to be several methods, but one of them that I ...
0
votes
0answers
28 views

How to detect in a bash script if it is used as a login shell? [duplicate]

I already have a bash script acting as a login shell, as an example: #!/bin/bash echo "this is a login shell" # do some other initialization bash Now I want to execute this script at other ...
34
votes
2answers
170k views

How to change from csh to bash as default shell

I have csh as my default shell, as shown by echo $SHELL. I want to switch to bash as my default shell. I tried the following approaches to no avail: With chsh I get: chsh: can only change local ...
4
votes
1answer
2k views

How can I check if a shell is login/interactive/batch in fish?

I want to be able to check if a fish shell is being run in login, interactive, or batch mode, and this question only discusses bash.
1
vote
4answers
6k views

log out via shell script

I am doing some operation via shell script. If that script is successful, continue else logout of the current user. I am unable to find a way to logout of current user. I tried to use exit but seems ...
2
votes
2answers
687 views

How to get the name of the nearest interactive ancestor shell from a script?

I know that one can use the $- contains i or not or check if $PS1 is empty to tell if a shell is interactive. However, those solutions only work for the current shell. I have a bash script trying to ...
3
votes
1answer
1k views

Why is my winscp session not showing in Linux?

When someone open the sessions using Winscp its session is not showing in Linux when I run who or last commands. I thought that it will appear because it is using ssh to connect. But still there are ...
0
votes
1answer
893 views

How to determine if script is called by interactive shell or another script?

It's fairly straightforward to determine from within a script that the code being run is not running in an interactive shell, but you already know that as you write the script, so I'm not sure how it'...
1
vote
2answers
94 views

Is it possible to findout if our command is sourced from a script or manually typed on command line?

We have an implementation to set environment for a particular tool with our custom command. Eg: custom_command tool_name This command logs the invokation time, user and tool_name in a log file. And ...