Operating System - HP-UX
1753261 Members
4887 Online
108792 Solutions
New Discussion

sh: Execute permission denied

 
Santhosh_Kumar
Occasional Advisor

sh: Execute permission denied

Hello,

 

I'm getting an "execute permission denied" error though my file has "-rwxrwxrwx" permission, while executing a C object file (real_time.o) through makefile.

 

Error Desc:

------------

sh: ./real_time.o: Execute permission denied.
*** Error exit code 1

 

 

OS Version:

-------------

HP-UX netomy1 B.11.23 U ia64 0975212021 unlimited-user license

 

/usr/bin/sh --> "-r-xr-xr-x"

 

Could anyone please help in resolving this error?

 

- Santhosh

12 REPLIES 12
Patrick Wallek
Honored Contributor

Re: sh: Execute permission denied

It may be that the executable file cannot be run on your system.

 

What model of server?  Is HP-UX 32-bit or 64-bit?

 

# model

# getconf KERNEL_BITS

 

Run the 'file' command against the executable like this:

 

# file real_time.o

 

 

Steven Schweda
Honored Contributor

Re: sh: Execute permission denied

> sh: ./real_time.o: Execute permission denied.

> /usr/bin/sh --> "-r-xr-xr-x"

   The problem is not with the permissions of "/usr/bin/sh".
"/usr/bin/sh" is complaining about "./real_time.o".

   How did you create "./real_time.o"?  A normal object file, like, say,
output from a command like:
      cc -c real_time.c
is not executable.  It's not a file-system permissions problem.  There's
a difference between an object file (".o", compiler output) and an
executable file ("a.out", linker output).

   What, exactly, are you trying to do?

Santhosh_Kumar
Occasional Advisor

Re: sh: Execute permission denied

Hi Patrick,

 

Below are the details you asked for

 

getconf KERNEL_BITS -> 64

 

model ->  ia64 hp server rx2660

 

file real_time.o -> real_time.o:    ELF-32 relocatable object file - IA64

 

Thanks,

Santhosh

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Hi Steven,

 

I am new to makefile. 

 

I am trying to modify the existing makefile sample delivered by the vendor to link my "real_time.c"  and the api library.

 

'real_time.o' is generated by makefile (makefile_rt) using the command ->  make -f makefile_rt all

 

Makefile Details:

------------------

 

# Using libapi.so/sl
ARBOR_LIBS = -lapi

# End of Using libapi.so/sl

#@echo $(ARBORSITE)

 

# Using libapi.a
ARBOR_LIBS = -lapi -ltablapi -lmpstsender -lducm_apisupport -lducm_manager -lducm_data \
-lmpssupport -lmpsmiddleware -lmps_cache -lACE \
-llate_fee -lacct_balance -lrc \
-larbor_init_thread -larbor_ipc -larbor_provlib -loam_emit -larbor_dbutils \
-larbor_$(DBMS:80=) -larbor_utils -larbor_zlib \
-larbor_thread -larbor_basiclib \
-ltax -lgeo -ltaxcommon -lbp_common \
$(LSALES) $(LCUSTOM) $(LCOMM) \
-lbtunicode
# End of Using libapi.a

#EXTRA_LDIR =

 

 

LDFLAGS = -L$(ARBORSITE)/lib -L$(ARBORDIR)/3p/rosette/lib $(EXTRA_LDIR)

LIBS     = $(ARBOR_LIBS) 

 

RT_SOURCES = real_time.c common.c

RT_OBJECTS = $(RT_SOURCES:.c=.o)


all: rt_call

 

rt_call: $(RT_OBJECTS) common.h
$(LINK) $(RT_OBJECTS) $(LINKFLAGS) $(LDFLAGS) $(LIBS) -o $@

 

 

Thanks,

Santhosh

 

Dennis Handly
Acclaimed Contributor

Re: sh: Execute permission denied

>while executing a C object file (real_time.o) through makefile.

>ELF-32 relocatable object file - IA64

 

As Steven said, object files can't be executed.  They first must be made into a load module using ld(1) or by using the cc(1) driver to link.

 

>I am trying to modify the existing makefile sample delivered by the vendor to link my real_time.c and the api library.

>real_time.o is generated by makefile using the command ->  make -f makefile_rt all

 

The main output of that makefile is rt_call, not real_time.o.

Santhosh_Kumar
Occasional Advisor

Re: sh: Execute permission denied

Hi Dennis,

 

I do agree that main output will be rt_Call, but real_time.o file got generated when I executed the make command (as highlighted earlier).

 

I am not trying to manually execute the C object file, it is executed as part of 'make' execution and the execute permission error is thrown

 

Thanks,

Santhosh

 

 

 

 

Dennis Handly
Acclaimed Contributor

Re: sh: Execute permission denied

>I am not trying to manually execute the C object file, it is executed as part of make execution

 

Then you need to add debugging statements in your makefile or use "make -d".

For each rule add:

        echo "Building: $@"

 

But this is most likely because $(LINK) isn't defined.

LINK = $(CC)

Santhosh_Kumar
Occasional Advisor

Re: sh: Execute permission denied

Hi Dennis,

 

As per your suggestion I defined LINK -> LINK = $(CC) and now I'm getting a different below error,

 

ld: Can't find library or mismatched ABI for -lapi
Fatal error.
*** Error exit code 1

 

All the libraries are placed in $ARBORSITE/lib path which I already inlcuded in the makefile

 

Also included /usr/lib/hpux32, should I need to place the necessary library files (.so) in  path "/usr/lib/hpux32" ?

 

Updated makefile contents (sharing only the modified contents from initial) :

 

IFLAGS = $(EXTRA_INCL) -I$(ARBORSITE)/include -I.
LIBS = $(ARBOR_LIBS)

LINK = $(CC)

CFLAGS = $(IFLAGS) $(EXTRA_INCL) $(DEBUG_FLAGS)
LDFLAGS = -L$(ARBORSITE)/lib -L$(ARBORDIR)/3p/rosette/lib $(EXTRA_LDIR) -L/usr/lib/hpux32

YFLAGS = -d

RT_SOURCES = real_time.c common.c

RT_OBJECTS = $(RT_SOURCES:.c=.o)


all: rt_call

rt_call: $(RT_OBJECTS) common.h
$(LINK) $(RT_OBJECTS) $(LINKFLAGS) $(LDFLAGS) $(LIBS) -o $@

 

Thanks,

Santhosh

 

 

 

 

Dennis Handly
Acclaimed Contributor

Re: sh: Execute permission denied

>ld: Can't find library or mismatched ABI for -lapi

 

Either the lib isn't in any -L paths or it is a 64 bit lib.

What does this show: file libapi.so

 

>should I need to place the necessary library files (.so) in  path "/usr/lib/hpux32"?

 

Well, if it is in any of your -L paths, you shouldn't need to do that.

 

>LDFLAGS = -L$(ARBORSITE)/lib -L$(ARBORDIR)/3p/rosette/lib $(EXTRA_LDIR) -L/usr/lib/hpux32

 

Never add the default paths to the link line: -L/usr/lib/hpux32

Let the driver figure this out.

Santhosh_Kumar
Occasional Advisor

Re: sh: Execute permission denied

Dennis,

 

Either the lib isn't in any -L paths or it is a 64 bit lib.

What does this show: file libapi.so  -->  libapi.so: ELF-64 shared object file - IA64

 

As you said its a 64bit lib.

 

Please advise on the next course of action, I have no clue to proceed further.

 

 

Never add the default paths to the link line: -L/usr/lib/hpux32

 

I'll refrain from defining the default paths going further, removed it in the existing file.

 

Thanks,

Santhosh