[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

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

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?


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


>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



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 | Search | Web FAQs | Documents | RFC Index ]

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

Last Update November 22 2008 @ 00:12 AM

© 2008 FAQS.ORG. All rights reserved.