Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

Unix - Frequently Asked Questions (5/7) [Frequent posting]
Section - How can I tell if I am running an interactive shell?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Cities ]


Top Document: Unix - Frequently Asked Questions (5/7) [Frequent posting]
Previous Document: How are shell variables assigned?
Next Document: What "dot" files do the various shells use?
See reader questions & answers on this topic! - Help others by sharing your knowledge
>From: dws@ssec.wisc.edu (DaviD W. Sanderson)
Date: Fri, 23 Oct 92 11:59:19 -0600

5.5)  How can I tell if I am running an interactive shell?

      In the C shell category, look for the variable $prompt.

      In the Bourne shell category, you can look for the variable $PS1,
      however, it is better to check the variable $-.  If $- contains
      an 'i', the shell is interactive.  Test like so:

          case $- in
          *i*)    # do things for interactive shell
                  ;;
          *)      # do things for non-interactive shell
                  ;;
          esac

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: Unix - Frequently Asked Questions (5/7) [Frequent posting]
Previous Document: How are shell variables assigned?
Next Document: What "dot" files do the various shells use?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
tmatimar@isgtec.com (Ted Timar)





Last Update March 27 2014 @ 02:12 PM