Operating System - HP-UX
1847196 Members
4423 Online
110263 Solutions
New Discussion

Re: shell script doesn't run

 
SOLVED
Go to solution
Igor Sovin
Super Advisor

shell script doesn't run

Hi!

I have priblem running script which starts with
#!/bin/sh.
When I run it as root it works fine, but it doesnt run under another user, although all permissions are set correctly.

here is ls -l:

kate:oraslp 7> ls -l
total 384
lrwxr-xr-x 1 oraslp dba 37 Jul 20 09:49 920_64 -> /export/oracle/SLP/platform/HPUX-IA64
-rwxr-xr-x 1 oraslp dba 33566 Sep 6 09:01 R3COPY
drwxr-xr-x 3 oraslp dba 8192 Mar 11 2002 mirrlogA
drwxr-xr-x 3 oraslp dba 8192 Mar 11 2002 mirrlogB
drwxr-xr-x 4 oraslp dba 40960 Aug 22 08:44 oraarch
drwxr-xr-x 3 oraslp dba 8192 Nov 7 2003 origlogA
drwxr-xr-x 3 oraslp dba 8192 Mar 11 2002 origlogB
drwxr-xr-x 2 oraslp dba 8192 Sep 5 06:00 saparch
drwxr-xr-x 2 oraslp dba 8192 Sep 4 23:50 sapbackup
drwxr-xr-x 2 oraslp dba 8192 Sep 5 07:02 sapcheck
drwxr-xr-x 18 oraslp dba 8192 Jul 28 2004 sapdata1
drwxr-xr-x 27 oraslp dba 8192 Feb 10 2005 sapdata2
drwxr-xr-x 42 oraslp dba 8192 Aug 26 2004 sapdata3
drwxr-xr-x 40 oraslp dba 8192 Sep 30 2005 sapdata4
drwxr-xr-x 26 oraslp dba 8192 Feb 13 2006 sapdata5
drwxr-xr-x 14 oraslp dba 8192 Aug 30 2004 sapdata6
drwxr-xr-x 3 oraslp dba 8192 Sep 5 10:29 sapreorg
drwxr-xr-x 4 oraslp dba 96 Jul 20 09:43 saptrace

R3COPY is the script that I told about.
12 REPLIES 12
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: shell script doesn't run

First, your shebang should be /usr/bin/sh not /bin/sh. Secondly, while the permissions of the RCOPY script/program are ok (and I question if this should be executable by anybody -I would change the mode to 750 rather than 755), it's probably the permissions of some other commands/executables/files/directories within the script itself that is the problem. I would add a "set -x" near the top of the RCOPY script and that should tell you where the script is failing. This applies if R3COPY is a script; if it is a true executable then run it under TUSC to see where the error occurs.

It really helps when you post the exact error message; otherwise, I have to use "The Force".

If it ain't broke, I can fix that.
Hein van den Heuvel
Honored Contributor

Re: shell script doesn't run

Apparently it is not a problem with the protection of the script, but with priviliges needed for an action triggered by the script.

Are all environment variables in place before the run

- What is the exact error message?
- How far does it get in the script?
- Run it with debug output ( -x ) ?
- 'diff' output form env for root and for the other user?
- Cut & paste individual commands from the script and try them?

Sounds like the script want to copy Oracle files around. Doe the other user (oraslp?) have write privs for the target? read privs for the source?

You can figure this one out!
We know you can!

Good luck,
Hein.



Igor Sovin
Super Advisor

Re: shell script doesn't run

Hi guys!

However, I dont get any error after starting script. It simply does nothing:

kate:oraslp 6> ./R3COPY
kate:oraslp 7>

Setting the "set -x" also didn't show any error.
Sandman!
Honored Contributor

Re: shell script doesn't run

Could you attach the script so that it can be looked at?

thanks!
Igor Sovin
Super Advisor

Re: shell script doesn't run

Hi!

The script is in attachment
Frank de Vries
Respected Contributor

Re: shell script doesn't run

I looked at your script, at first sight there
seems nothing out of the ordinary.
There are a couple of exit conditions like
ORACLE_HOME not set, or Oracle not available etc.. , but then you should see an error produced by the script onto your terminal.

So the fact that you get no output at all looks like a fork or exec problem.
Possibly due to something in the environment
But in all honesty I can't explain it yet.

When you run the script like this

oraslp>sh -xv R3COPY

You do not get any output at all ,
not even the verbose info?

By the way this oraslp it is a cshell or not ? And what are your terminal settings ?
When you do ps -ef | grep -i R3COPY is it still in memory ?

Hope we can move on from here.

Look before you leap
Peter Godron
Honored Contributor

Re: shell script doesn't run

Igor,
1. Are non-root users allowed by directory to run the file?
2. Check the shell:
ll /usr/bin/sh [ -r-xr-xr-x ]?
3. Change your first lines:
#!/usr/bin/sh
echo hello
exit
Igor Sovin
Super Advisor

Re: shell script doesn't run

Frank,

here is the output of sh -xv:

kate:oraslp 12> sh -xv R3COPY
# *********************************************************************
# ***********************************************************************
# **** ****
# *** $HOME/.kshrc ***
# *** login script for KORN-shell ***
# *** ***
# *** To facilitate Hotline Support nothing should be ***
# *** changed. If necessary site-specific modifications ***
# *** can be included in the file .customer.sh ***
# *** which will be sourced by this script. See Section : ***
# *** ***
# *** # User specific environment ***
# *** ***
# *** Copyright (c) 1993 SAP-AG ***
# *** ***
# *** @(#) Version: %I% Date %E% ***
# *** ***
# ***********************************************************************
# *********************************************************************

# RDBMS environment
if [ -f $HOME/.dbenv_`hostname`.sh ]; then
. $HOME/.dbenv_`hostname`.sh
elif [ -f $HOME/.dbenv.sh ]; then
. $HOME/.dbenv.sh
fi
+ hostname
+ [ -f /oracle/SLP/.dbenv_kate.sh ]
+ [ -f /oracle/SLP/.dbenv.sh ]

# 16/05/99 Assa added for Backup OmniBack
OB2BARLIST=SLP
+ OB2BARLIST=SLP
export OB2BARLIST
+ export OB2BARLIST

# User specific environment
if [ -f $HOME/.customer.sh ]; then
. $HOME/.customer.sh
fi
+ [ -f /oracle/SLP/.customer.sh ]

# Say good bye for non interactive shells
case $- in
*i*);;
*) return 0;;
esac
+ return 0
kate:oraslp 13>

oraslp is a cshell user.
ps -ef |grep -i R3COPY shows that process not in memory.

Peter,
1)Permissions on /usr/bin/sh is correct
2) After changing first lines i see "hello" in the output, it work fine.
Frank de Vries
Respected Contributor

Re: shell script doesn't run

Ah, we can see now where and why it exits.

It says that no option was passed to the ksh shell and exits.

Before you run the script,
can you first type ksh
at your cshell prompt of oraslp.
And then run the script again.

Let me know if that does it,
Also in combination with the ksh shell you can change the first line in your script to #!/sbin/ksh

If this does not work I need to do some research on this interactive shell thing; but we are getting closer :) :)
Look before you leap
Igor Sovin
Super Advisor

Re: shell script doesn't run

Okay

kate:oraslp 3> ksh
kate:oraslp> ./R3COPY
kate:oraslp>

Unfortunetly no result.
Igor Sovin
Super Advisor

Re: shell script doesn't run

but it runs when I change the first line in my script to #!/usr/bin/ksh
Bill Hassell
Honored Contributor

Re: shell script doesn't run

It's important to know why /usr/bin is the correct location. In HP-UX (and other SysV Unix flavors like Solaris), the /bin directory no longer exists. To verify this, type the command:

ls -ld /bin

It is not a directory but a temporary link so script writers can change their interpreter line (#!/usr/bin...). Linux and other BSD versions still use /bin so it is important to remember the differences. /bin has not existed for more than 10 years in HP-UX.

Since the set -x did not work, the script did not run. The alternate method is to to place the -x trace on the command line as in:

ksh -x ./R3COPY


Bill Hassell, sysadmin