LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-21-2017, 08:14 AM   #1
UltraPain
Member
 
Registered: Jun 2006
Posts: 32

Rep: Reputation: 3
Logic - Am I running interactively or no?


Hi all,

I've found several hits in researching my issue, but none seem to touch on my exact issue. When logging into my RHEL 6 server as the oracle user (korn shell), .profile calls the oraenv script to set the environment, which prompts the user for input. I'm trying to write logic that says, in pseudo-code:

if this session is interactive, run oraenv
else, don't

Oracle delivers init scripts to start and stop oracle services on shutdown and startup. The scripts use the su - oracle -c blah syntax to stop and start oracle services, but because .profile calls oraenv, the system is prompted for input.

Thanks!
 
Old 03-21-2017, 01:51 PM   #2
UltraPain
Member
 
Registered: Jun 2006
Posts: 32

Original Poster
Rep: Reputation: 3
problem solved

the logic I used to resolve this is:

if tty -s ; then
my settings
fi
 
Old 03-21-2017, 01:54 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Usually there are already tests in startup scripts to determine if a login is interactive versus not. Either case, the old BASH tried and true has always worked for me:
Code:
if [ -z "$PS1" ]; then
        echo This shell is not interactive
else
        echo This shell is interactive
fi
Or the other form typically found in the .bashrc file:
Code:
case "$-" in
*i*)	echo This shell is interactive ;;
*)	echo This shell is not interactive ;;
esac

Last edited by rtmistler; 03-21-2017 at 01:55 PM. Reason: Edit: Sorry I think you solved and updated just as I was composing this.
 
Old 03-23-2017, 11:49 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748
There are some methods here http://www.tldp.org/LDP/abs/html/intandnonint.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Internal Logic failure while running fsck.ocfs2 divya.gurusamy@gmail.com Linux - Software 0 10-08-2014 05:45 AM
problems running C-embedded Python interactively in a pty ta0kira Programming 4 07-23-2012 10:25 PM
LSI Logic / Symbios Logic 53c875 (rev 14) -> HP Storageworks 1/8 G2 gileravxr Linux - Hardware 0 07-21-2009 04:45 AM
Booting Interactively and saying NO to the following: salmanal Fedora 6 06-26-2006 06:48 PM
Hows Linux for running Logic And Cubase? zidane2010 Linux - General 3 03-25-2004 07:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration