- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- start program in the background HP-UX problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 04:09 AM
тАО08-02-2010 04:09 AM
I need help for solving this problem.
I have a simple script (i wish to execute in the background) like:
#!/bin/ksh
su - oracle -c "whoami" > /tmp/test1.txt
When I execute it:
1) Normally (not in the background)
bash-4.1# ./test.sh
ls -altr
-rw-r----- 1 root sys 111 Aug 2 11:00 test1.txt
You can see that output output file is created.
2) In the background
bash-4.1# ./test.sh &
ls -altr
[1]+ Stopped ./test.sh
ls -altr test1.txt
-rw-r----- 1 root sys 0 Aug 2 11:04 test1.txt
Like you can see file is created, but it's empty. Also background job is stopped.
Can anybody help me to find way to execute this script in the background on my HP-UX machine (it's a HP-UX mitist1 B.11.31 U ia64).
Best regards,
Dragan
Solved! Go to Solution.
- Tags:
- background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 04:18 AM
тАО08-02-2010 04:18 AM
Re: start program in the background HP-UX problem
This means your .profile is broken, it is trying to read from stdin.
If you don't want to fix it, you can try:
./test.sh < /dev/null &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 04:26 AM
тАО08-02-2010 04:26 AM
Re: start program in the background HP-UX problem
When I have execute this, I get
#mitist2.it.telekom.yu>./test.sh < /dev/null &
[1] 23109
#mitist2.it.telekom.yu>stty: : Not a typewriter
stty: : Not a typewriter
stty: : Not a typewriter
What are my options?
I send you the profile file.
Best regards,
Dragan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 04:26 AM
тАО08-02-2010 04:26 AM
SolutionWell you really aren't using HP-UX 11.31 here. You are using the bash shell, which behaves differently and sometimes less reliably than the POSIX or korn shell.
Alternatives.
nohup ./test.sh &
Try ksh or posix shell
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 04:40 AM
тАО08-02-2010 04:40 AM
Re: start program in the background HP-UX problem
Well, did you get what you wanted in /tmp/test1.txt? If so, you are done.
>I send you the profile file.
This is HP's broken /etc/profile and you'll have to fix it. But only the login shell should invoke /etc/profile, so there may be something wrong with your .profile or whatever bash uses.
Most likely: stty erase $ERASE
If you look you'll see some threads from Bill about this:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1206345
>SEP: Try ksh or posix shell
Unfortunately these may fail the same way? :-(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 04:40 AM
тАО08-02-2010 04:40 AM
Re: start program in the background HP-UX problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 04:43 AM
тАО08-02-2010 04:43 AM
Re: start program in the background HP-UX problem
> stty: : Not a typewriter
What are my options?
As Dennis said, there are interactive commands (namely 'tset' and 'stty') that are being invoked when your profile is read (as a consequence of the 'su - ' command.
You have several alternatives:
(1) don't use 'su -' but rather use 'su'. This form will not source (read) the profile. Hence, none of the 'oracle' environmental variables will be applied either and this may not be what you want.
(2) Condition the block of code that does the interactive commands in the '.profile' to only execute if the environment is associated with a tty:
if [ -t 0 ]; then #...interactive
...
fi
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 05:15 AM
тАО08-02-2010 05:15 AM
Re: start program in the background HP-UX problem
In batch (script) mode, there is no controlling terminal (tty) so commands that work fine when you login (tset, stty, tabs, ttytype, tput, and so on) will give you errors like "not a typewriter" and other errors.
To fix this situation, you must examine the oracle user's profile for any of the above commands, then protect them as James points out above. Once protected, both batch and interactive sessions will work correctly.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 10:02 PM
тАО08-02-2010 10:02 PM
Re: start program in the background HP-UX problem
I have tried first option without su - oracle, just su oracle and this is works, like you said.
Only problem is because I must always use absolute path to the names of executables i am using in the script.
Because I haven't to much experience in the shell programming how to setup this profile file so it would be valid when I am using su - oracle in the script.
I send you the profile files from both (root and oracle) user.
For root (profile)
For oracle (.profile)
When I am first log on to the server, and type: echo $SHELL
I get: /sbin/sh
You can see here that in oracle .profile I have this problematic stty erase, I have tried to comment it but nothing happened, I get the same problem.
Best regards,
Dragan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 10:32 PM
тАО08-02-2010 10:32 PM
Re: start program in the background HP-UX problem
This is shells 101. You need to update your $PATH.
>You can see here that in oracle .profile I have this problematic stty erase, I have tried to comment it but nothing happened, I get the same problem.
If you comment it out, you should have fewer error messages. But instead of commenting it, you should fix it as JRF said. You could either add another if - fi block or fiddle with the one you have:
if [ ! "$VUE" -a -t 0 ]; then
If this doesn't fix them all, you need to fix the broken /etc/profile that HP supplies.
(Has anyone ever filed a bug report on this broken file?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2010 11:13 PM
тАО08-02-2010 11:13 PM
Re: start program in the background HP-UX problem
I have changed the line
if [ ! "$VUE" ]; into if [ ! "$VUE" -a -t 0 ];
and I have the same problem.
I send you the new modificated file .profile for oracle user.
Regards,
Dragan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 04:13 AM
тАО08-03-2010 04:13 AM
Re: start program in the background HP-UX problem
Yet another option is to collect the Oracle environmental variables you need into a separate file that can be sourced (read). This obviates the need to cause the '.profile' to be read when you do 'su - oracle'. Instead you would do something like:
# cat /home/oracle/oravars
ORACLE_HOSTNAME=mitist2.it.telekom.yu; export ORACLE_HOSTNAME
ORACLE_UNQNAME=tis; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/db; export ORACLE_HOME
GRID_HOME=/u01/app/11.2.0/grid; export GRID_HOME
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$GRID_HOME/bin:$PATH; export PATH
ORACLE_SID=tis2; export ORACLE_SID
# su oracle -c '. /home/oracle/oravars && /tmp/test.sh' > /tmp/test.log
Since this is an 'su' without the '-' option, the '.profile' isn't read. The switch to the oracle user is made, though and the 'oravars' file sourced and the 'test.sh' is run in that environment.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 04:26 AM
тАО08-03-2010 04:26 AM
Re: start program in the background HP-UX problem
I meant to add that is you choose to isolate the environmental variables you need for your 'oracle' user in a separate "include-able" file as I showed above, you can remove them from the oracle's '.'profile' too. Now, you have only one palce to maintain your environmental variables but they are available however and whenever you need them. Simply substitute the "dot-space-file" line at the end of the oracle profile. Using the name I suggested before, this would look like:
. /home/oracle/oravars
This syntax causes the file to be read ("sourced" or "included") into the *current* environment. Note very carefully the dot ('.') followed by a whitespace character, followed by the file to be sourced.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 05:24 AM
тАО08-03-2010 05:24 AM
Re: start program in the background HP-UX problem
Not really, you should have fewer error message. The problem is now only in /etc/profile and you'll need to fix that file too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 09:24 PM
тАО08-03-2010 09:24 PM
Re: start program in the background HP-UX problem
Tell me is it reasonably to change the predefined root profile. Can I get some kind of consequences.
Finally what lines I need to change here (I am sending you the root profile file).
Thanks for all your time and effort.
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 10:30 PM
тАО08-03-2010 10:30 PM
Re: start program in the background HP-UX problem
It would be better if it was reported and HP fixed it.
You already have modified the end of the file.
I don't see anything going wrong except fixing the nasty message.
>Finally what lines I need to change here (I am sending you the root profile file).
Add the following if and fi around that stty:
if [ -t 0 ]; then
stty erase $ERASE
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 11:11 PM
тАО08-03-2010 11:11 PM
Re: start program in the background HP-UX problem
I have changed profile fiel from /etc directory.
I send you the file.
Earlier I have changed the .profile for oracle user.
But, again when I have tried to execute the simple script:
#!/bin/ksh
su - oracle -c "whoami" > /tmp/test1.txt
in the background with
./test.sh &
I get the blank file like earlier.
Thanks,
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2010 02:18 AM
тАО08-04-2010 02:18 AM
Re: start program in the background HP-UX problem
>I get the blank file like earlier.
You must use:
>./test.sh < /dev/null &
Or you need to add that inside your test.sh script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2010 02:35 AM
тАО08-04-2010 02:35 AM