Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

executing a UNIX shell script using SM49

Former Member
0 Kudos

I have been trying all sorts of things to get this to work and I have been un-successful

I am trying to run the UNIX script using SM49. the command line that I am using is

/test/directory/bin/testmail.sh

the script testmail.sh looks like

#!/bin/ksh

/usr/bin/mailx -s testmail <email address>

I have tried all sorts of combinations to run this script

example

sh /test/directory/bin/testmail.sh

/test/directory/bin/testmail.sh %f

/test/directory/bin/testmail.sh %F

does anyone have any suggestions on how to get this to run successfully. once I get this to run successfully in SM49, I am going to try it in the intregration builder of my PI process.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Are you getting any error message?

11 REPLIES 11

Former Member
0 Kudos

Are you getting any error message?

0 Kudos

I am getting the following

Can't exec external program (No such file or Directory) External program terminated with exit code 1

0 Kudos

If you are sure /test/directory/bin/ exists and the file exists, check if you have permission issues. Can you log onto the operating system and navigate to this directory and execute this shell script? If not, then it is you who do not have access to this directory and the file.

0 Kudos

I do not have access to the operating system

the only way I know of to access the operating system to do UNIX commands is thru SM49

0 Kudos

So that is probably your problem. Even SM49 will use your user ID to check the permissions. Check with someone in basis who has access and test it through them or get the access and test yourself.

0 Kudos

Hi,

considering authorization issues, you can use

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
    EXPORTING
      commandname                         = 'LIST_DB2DUMP'
      additional_parameters               = l_path
     operatingsystem                      = 'UNIX'
    TABLES
      exec_protocol                       = lt_btcxpm
...
    EXCEPTIONS

to extract information about files on the server

I used this code to get detailed information for display including the attributes

LOOP AT lt_btcxpm ASSIGNING <btcxpm>
    WHERE length > 57
      AND ( NOT message+57 CO '. '
            OR  message+57 = '..' )
      AND ( message(1) = 'd' OR
            message(1) = 'l' OR
            message(1) = '-' ).
    l_srvfil-type  = <btcxpm>-message(1).
    IF l_srvfil-type  = '-'.
      l_srvfil-type = 'F'.
    ENDIF." l_srvfil-type  = '-'.
    TRANSLATE l_srvfil-type TO UPPER CASE.               "#EC TRANSLANG
    l_srvfil-file  = <btcxpm>-message+57.
    CONDENSE l_srvfil-file.
    l_srvfil-attri = <btcxpm>-message+1(9).
*    l_srvfil-time = <btcxpm>-message+44(12).
    l_srvfil-size = <btcxpm>-message+32(11).
    APPEND l_srvfil TO lt_srvfil.
  ENDLOOP." at lt_BTCXPM assigning <BTCXPM>.
  pt_srvfil = lt_srvfil.

For the srvfil information I used this structure

BEGIN OF typ_srvfil,
  %_box  TYPE flag,                                         "#EC *
  type   TYPE char01,
  attri  TYPE isp_rel,
  file   TYPE file,
  name   TYPE file,
  size   TYPE sytleng,
  owner  TYPE sy-uname,
  mod_date TYPE sydatum,
  mod_time TYPE syuzeit,
  END OF typ_srvfil,

I do not remember exactly how the attribute information is resolved. In Unix all file system authorizations can be set as for the user, the group or for all and it can be read, write, execute granted. If you are no unix expert, ask one or google/wiki for some details.

I wrote a program for navigation, display, and some more functions on the file system which is too big to post here and is not fully system-independent. Not perfect but useful and more than 5 years old. Contact me by mail if you want it.

Regards,

Clemens

Edited by: Clemens Li on Oct 23, 2009 9:16 PM

0 Kudos

the problem is solved.

there were special characters in the sheel script taht I did not know about. the UNIX admin had to use VI to edit the file and remove the characters.

0 Kudos

Hi Everyone,

I have the same problem, but I create the SH on the VI editor directly on our AIX.

So, this don't solve my issue.

Can anyone help me?

Thanks a lot.

Sebastian.

0 Kudos

Hi,

i created command using sm69 and assign the unix path and file. it is working when the file is having Read, write and execute permission.

for some security reason my administrator not giving the above permission.

is it possible to execute the unix script without permission. if possible then how?

Thanks.

Muthuraj.D

0 Kudos

Hi,

sorry, this is unix: No authorization, no way.

Regards,

Clemens

0 Kudos

Keep in mind that a Unix/Linux command or a Unix/Linux script has to run in a shell (Korn, Bash, etc). If the path to your shell is not found, you'll get that failure "No such file or directory". So if you've confirmed that the script is indeed where it should be and that the permissions are what they should be, you might also have your Unix/Linux team confirm that the shell path is ok.

On our new RHEL5 servers, we had to put this link out there to resolve the problem:

ln -s /bin/bash /usr/bin/sh