Operating System - HP-UX
1829104 Members
3012 Online
109986 Solutions
New Discussion

Problem Start Shell in background

 
cocoluigi
New Member

Problem Start Shell in background

Hello..
when I start a shell in background ex:
nohup myshell.sh &
return
[1] + Stopped (tty output) nohup myshell.sh &
more nohup.out
Not a terminal

this is my .profile

# @(#)B.11.11_LR
# Default user .profile file (/usr/bin/sh initialization).

# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff
tabs

# Set up the search paths:
PATH=$PATH:.

# Set up the shell environment:
set -u
trap "echo 'logout'" 0

# Set up the shell variables:
EDITOR=vi
export EDITOR


How can I solve this problem
Thanks in winter!!!
12 REPLIES 12

Re: Problem Start Shell in background

Why are you showing us your .profile? I think we would be more interested in the contents of myshell.sh

HTH

Duncan

I am an HPE Employee
Accept or Kudo
cocoluigi
New Member

Re: Problem Start Shell in background

this is content of myshell.sh

#########################

. $HOME/.profile
sqlplus -S user/user <spool query.log
@/export/home/oracle/query.sql
spool off
EOF

########################

Re: Problem Start Shell in background

(I won't comment on the sense of sourcing a .profile in a non-interactive script)

Then the problem is the tset commands in your .profile

Chnage your .profile to look like this:

# @(#)B.11.11_LR
# Default user .profile file (/usr/bin/sh initialization).

if /usr/bin/tty -s
then
# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff
tabs
fi

# Set up the search paths:
PATH=$PATH:.

# Set up the shell environment:
set -u
trap "echo 'logout'" 0

# Set up the shell variables:
EDITOR=vi
export EDITOR




HTH

Duncan

I am an HPE Employee
Accept or Kudo
cocoluigi
New Member

Re: Problem Start Shell in background

Sorry!! the problem persists
However, many thanks....

Re: Problem Start Shell in background

oops sorry...

try replacing

if /usr/bin/tty -s

with

if [ -o interactive ]



HTH

Duncan

I am an HPE Employee
Accept or Kudo
Sandman!
Honored Contributor

Re: Problem Start Shell in background

How about the nesting the test for the TERM variable within the test for interactive or batch mode of operation i.e.

if [ -t ]; then
if [ "$TERM" = ""]; then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
fi
Peter Nikitka
Honored Contributor

Re: Problem Start Shell in background

Hi,

read Sandman's first line as
if [ -t 1 ]; then

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
cocoluigi
New Member

Re: Problem Start Shell in background

Thanks everyone! ! I have tried all your suggestions
But I did not understand why the problem persists
Peter Nikitka
Honored Contributor

Re: Problem Start Shell in background

Hi,

what about attaching your modified $HOME/.profile ?

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Bill Hassell
Honored Contributor

Re: Problem Start Shell in background

Based on your .profile, you don't need it at all. Everything in it refers to an interactive session and does not setup anything for your database environment. And since your example is just running the script from your current login, running .profile in the script makes no sense. Are you testing this script for a cron job? If so, then the environment you need was setup in /etc/profile. I would not try to source /etc/profile but instead, just add the needed environment commands into your script.


Bill Hassell, sysadmin
cocoluigi
New Member

Re: Problem Start Shell in background

Sorry!!!!
I had tried option
-o interactive

Now is OK!!!
Thanks to all for your help
Peter Nikitka
Honored Contributor

Re: Problem Start Shell in background

Hi,

nice to hear, that it works now! I think, now is the time for
http://forums1.itrc.hp.com/service/forums/helptips.do?#33

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"