Unix commands in ABAP

Hi,
   I need to call the following unix command in ABAP to encrypt a file on the app server .
crypt password <org filename> new_filename
1 But when i run it using call 'SYSTEM' .. i get message security risk , command not executed ..
2 I also created the command in SM69 and tries to run it but same error.
3 I also created a shell script , but i get another message when i try to run sh ...
  Please help to find out a way to make it work ..
Kunal

Hi kunal,
1. probably ur basis team might be able to help u.
2. even if we have authorisations thru sap
   to run external os command,
   the actual OS user on application server
   must have the right for it
   and access/write/read/modify
   for the files (provided thru the command)
   in question.
3. Due to this , the systems gives the message
   of SECURITY RISK.
regards,
amit m.

Similar Messages

  • I want to execute UNIX COMMAND in ABAP

    Hi All,
    I want to execute a UNIX XOMMAND sh <scriptname> <filename> to replace divsion codes.in ABAP.
    But, I came to know that we can't (2) or try the following program but unfortunately the command CALL SYSTEM is not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.
    REPORT ZUNIXCOM .
    DATA: U_COMMAND(200).
    Table for system messages
    DATA: BEGIN OF RT OCCURS 100 ,
    LINE(100) ,
    END OF RT .
    START-OF-SELECTION .
    MOVE 'unix command' to U_COMMAND .
    REFRESH RT.
    CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
    ID 'TAB' FIELD RT-SYS .
    LOOP AT RT.
    WRITE : / RT-LINE .
    ENDLOOP. 
    So please can u help me how to call a unix command from ABAP. it is very urgent. I want complete details and all possible solutions
    <removed_by_moderator>
    Thanks,
    gyanaraj
    Edited by: Julius Bussche on Aug 26, 2008 11:29 AM

    Selvaraj Gyanaraj wrote:>
    > So please can u help me how to call a unix command from ABAP.
    I was about to help you.
    >it is very urgent.
    I changed my mind.
    >I want complete details and all possible solutions
    I'm glad I changed my mind.
    >Points are surely rewarded.
    Too late.

  • UNIX command in ABAP code

    Hi All,
    I need to use unix command (MOVE) in ABAP code for transfering a file from one directory to another directory.
    Can any one help with how to used unix commands in ABAP?
    Thanks in advance.
    Regards,
    Hemendra

    The recommended approach always used to be to use transaction SM69 to define a "soft" command name to the operating system command so that it could be configured to work across Windows, Unix etc.  For example:
    Command name       OS         Type             OS command                                 Parameters for operating system command 
    Z_FILE_MOVE        SunOS      Customer    mv                                                 ? ?   
    You can then call function module SXPG_COMMAND_EXECUTE (quite well documented) to actually perform the command passing in the appropriate number of parameters.
    Jonathan

  • How to Move file / call UNIX command using ABAP Program

    Hi, ABAP Guru.
    I need to Cut & Paste file (Move file from one location to another location) on Network Shared Drive using ABAP program.
    But I can't figured out how to do this and what ABAP Command / FM / Method (and maybe UNIX command) that being used.
    Please give me the advice.
    Best regard and Thank you all.
    Nattapash C.

    all methods for your requirements should be in class CL_GUI_FRONTEND_SERVICES

  • Using Unix command in ABAP

    Hi guy,
    I am using " Call 'SYSTEM' id 'COMMAND' field UnixCommand id 'TAB' field itFiles-SYS"  to read number of files in folder, it works fine if number of line are around 200 but if its more then that it doesn't any file.
      UnixCommand = 'ls -ld'.
      UnixCommand+7(45) = /abap/.
      call 'SYSTEM' id 'COMMAND' field UnixCommand
                    id 'TAB' field itFiles-SYS.
    Thanks
    Atul

    Hi,
    DATA: L_DIRNAME LIKE EPSF-EPSDIRNAM,
          L_FILEMASK LIKE EPSF-EPSFILNAM.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
        EXPORTING
          dir_name                  = l_dirname
          file_mask                 = l_filemask
    * IMPORTING
    *   DIR_NAME                    =
    *   FILE_COUNTER                =
    *   ERROR_COUNTER               =
        TABLES
          dir_list                  = pi_filelist
    EXCEPTIONS
       invalid_eps_subdir           = 1
       sapgparam_failed             = 2
       build_directory_failed       = 3
       no_authorization             = 4
       read_directory_failed        = 5
       too_many_read_errors         = 6
       empty_directory_list         = 7
       OTHERS                       = 8.
    Try with this

  • Execute unix command in abap code

    Hi, I have a request to execute a script command in a remote unix server, should i use 'call function ...destination'?
    Thanks.
    Legend.

    Use like this :
    data: begin of t_tabl occurs 0,
    line(132),
    end of t_tabl,
    data: lc_command(100) type c.
    Get all the file name falling under specified directory...
    lc_command(3) = 'ls '.
    lc_command+3(45) = p_dir. " Directory of file path
    call 'SYSTEM' id 'COMMAND' field lc_command
    id 'TAB' field t_tabl-sys.
    Check any files exits in the directory.......................
    if t_tabl[] is initial.
    message e006 with 'No files exist in the specified directory ' p_dir.
    endif.
    Do not look for sy-subrc ,here sy-subrc will not work.
    Thanks
    Seshu

  • Unix Command to search file

    Hi
    Can anyone tell me how to get filename from server using
    UNIX command in ABAP program.I have requirement to search file in server using date criteria.
    should i use 'FIND' command to search file??
    Plz do needful..

    You need to use SM69 to define command and use it in your report.
    Regards,
    Christophe

  • How to generate a empty file in AL11 using ABAP and unix command

    Hi Experts,
    when load infopackage triggers it will search file from AL11 if file is available it will get loaded successfully.  When there is no file in AL11 error while opening file (orgin A) and the load will fail.  At this level i have to write a abap code using unix command to generate a empty file.
    Is there any way to achieve the above requirement.
    Thanks
    Vara

    Hi,
    If i get your requirement properly then you want to create a blank file if there is no file on the application server so that your infopackage does not fail, am i correct.
    If this is your requirement then this can be easily done if you use process chain to load the file via infopackage. Follow the following steps:
    1. Add a ABAP program before the infopackage and check if the file is present on the server or not. Use a simple ABAP statement OPEN DATASET <FNAME>. Check the SY-SUBRC after this statement if it is not 0 then it means that the file does not exist on the application server.
    2. Once you have established that the file is not present create a flat file using a code similar to the below one
    OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE
                          MESSAGE D_MSG_TEXT.
    IF SY-SUBRC NE 0.
      WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.
      EXIT.
    ENDIF.
    * Transferring Data
    LOOP AT INT_table.
      TRANSFER INT_table-field1 TO FILENAME.
    ENDLOOP.
    * Closing the File
    CLOSE DATASET FILENAME.
    3. Add your infopackage step after this ABAP program in your process chain.
    I hope this helps.
    Best Regards,
    Kush Kashyap

  • Shortdump while calling UNIX command

    Hi all,
    I have a problem while trying to remove a file in UNIX platform in ABAP program.
    It is working fine in the development and quality server, but not in production server.
    Based on the debug result, the shortdump was thrown while executing "CALL 'SYSTEM' ID 'COMMAND' FIELD lv_command".
    Below are the message return in the program shortdump
    How to correct the error                                  
        You can check the authorization beforehand with the   
        function module AUTHORITY_CHECK_C_FUNCTION.           
    Short text                                            
        No authorization to call the C function "SYSTEM". 
    DATA: lv_command(100) TYPE C,
            client_path LIKE RCGFILETR-FTAPPL,
            server_path LIKE RCGFILETR-FTAPPL.
      DATA: wa_files  TYPE rsfillst,
            it_files  LIKE TABLE OF wa_files.
      CALL FUNCTION 'SUBST_GET_FILE_LIST'
        EXPORTING
          dirname      = gv_unix
          filenm       = '*'
        TABLES
          file_list    = it_files
        EXCEPTIONS
          access_error = 1
          OTHERS       = 2.
      IF  sy-subrc = 0.
        LOOP AT it_files INTO wa_files WHERE TYPE <> 'directory'.
          CONCATENATE wa_files-dirname wa_files-name INTO server_path.
          CONCATENATE p_fname wa_files-name          INTO client_path.
          CALL FUNCTION 'C13Z_FILE_DOWNLOAD_ASCII'
            EXPORTING
              i_file_front_end    = client_path
              i_file_appl         = server_path
              I_FILE_OVERWRITE    = 'X'
            EXCEPTIONS
              FE_FILE_OPEN_ERROR  = 1
              FE_FILE_EXISTS      = 2
              FE_FILE_WRITE_ERROR = 3
              AP_NO_AUTHORITY     = 4
              AP_FILE_OPEN_ERROR  = 5
              AP_FILE_EMPTY       = 6
            OTHERS                = 7.
          IF sy-subrc = 0.
            concatenate 'rm -f' server_path into lv_command separated by space.
            condense lv_command.
            CALL 'SYSTEM' ID 'COMMAND' FIELD lv_command.
            CLEAR: lv_command.
          ENDIF.
        ENDLOOP.
      ENDIF.
    Anyone knows why and how to resolve this?
    Kindly provide your feedback and input. Thanks in advance.

    You don't have authorisation in PRD to remove files. If it is really required for you.
    Take SU53 screen shot  immediately once you get short dump and follow up with Basis Folks for required authorisation.
    Thanks,
    Raj

  • UNIX scripting in ABAP

    Hi Champs,
          I need integerate UNIX application in my ABAP program. Below are the list of requirements for which UNIX will be required:
    1) Need to move a file from one directory to another in Application server.UNIX command can be
    MV Source Target
    2) Need to search for a file in certain Directory.UNIX command can be
    LS <file> Directiories where in files to be search.
    Please can you help me out how to integerate UNIX code with ABAP report.
    Regards,
    Nishant Khimesra

    Nishant,
    To move a file from one directory to another in Application server.
    DATA: command LIKE rs37a-line.
    DATA: BEGIN OF tabl OCCURS 0,
              line(2000),
          END OF tabl.
    command = 'mv /tmp/file1.txt /usr/tmp/file1.txt'.
    CALL 'SYSTEM' ID 'COMMAND' FIELD command
                  ID 'TAB'     FIELD tabl-*sys*.
    To search for a file in certain Directory.
    DATA: command LIKE rs37a-line.
    DATA: BEGIN OF tabl OCCURS 0,
              line(2000),
          END OF tabl.
    command = 'ls /tmp/file1.txt '.
    CALL 'SYSTEM' ID 'COMMAND' FIELD command
                  ID 'TAB'     FIELD tabl-*sys*.
    Regards
    Sabu

  • Integrating External Operating System Commands into ABAP program.

    Hi folks,
    using the transaction code sm69 it is possible to create an SAP command that's executing an operating system command.
    Is it possible to integrate such an SAP command into our ABAP programs ?
    How would we do so ?
    Regards
    Thomas

    Hello Thomas,
    We have an easier way of achieving this without declaring a command in SM69.
    Try the below piece of code:
    DATA: command LIKE rs37a-line.
    DATA: BEGIN OF tabl OCCURS 0,
              line(2000),
          END OF tabl.
    command = 'ls -l'.
    CALL 'SYSTEM' ID 'COMMAND' FIELD command
                  ID 'TAB'     FIELD tabl-*sys*.
    Replace the string in the variable 'comand' with any UNIX command.
    Regards
    Sabu

  • Unix command execution

    Hi All,
    How to execute an UNIX command in SAP. I want to execute ls command from  sap. How to do that.
    Thanks.
    Moorthy.

    Hi,
    Refer to the SAmple program on the link.
    http://saplab.blogspot.com/2007/10/sample-abap-program-to-execute-unix.html
    Regards
    Sumit Agarwal

  • Unix command question on TAB content

    We found the following ABAP statemenet
    DATA: our_unix_path_and_file_name(64) TYPE c,
               v_unixcmd(255) TYPE c,
               result(255) TYPE c OCCURS 100 WITH HEADER LINE.
    CONCATENATE 'ls -al' our_unix_path_and_file_name INTO v_unixcmd SEPARATED BY space.
    CALL 'SYSTEM' ID 'COMMAND' FIELD v_unixcmd
                    ID 'TAB'     FIELD result-*sys*.
    The question is: is result an internal table? if it's an internal table, then why it's defined as type c?  And also what is included in this result after calling this UNIX command? it will list all the file content?
    Thanks and we will give you reward points!

    Hi,
    The result you'll get is a list of files and attributes from a directory and it will be placed in an internal table.
    Regards,
    Nicolas.

  • UNIX command and SXPG_COMMAND_EXECUTE

    HI all,
    Let me explain my requirement:
    I need to move all files from source dir to target.
    For that i need to read source dir and target dir from selection screen.
    I wrote UNIX command as follows:
    "mv -f /common/home/edw/parsekb/b2/* /common/home/edw/parsekb/b1"
    where i m specifying the src and target dir.
    so i need to pass the parmeters as srcdir and targetdir?
    how should i do it?
    i knw i need to create a command in SM69,then what will be the parameters in that case?
    and how to call that from ABAP ?
    if anybody give me explaination w.r.t. coding steps then that will be gr8.
    but pls specify SM69 steps and ABAP both
    Thanx in advance

    Hi!
    1. Create your shell script your_shell_script.sh:
    src=$1
    dst=$2
    mv -f $src $dst
    2. Create your command Z_YOUR_COMMAND using SM69:
    - Operating system command: /bin/sh (the path to your shell interpretator)
    - Parameters for operating system command:
    /home/sap/bin/your_shell_script.sh (the path to your shell script)
    - Set "Additional parameters allowed" checkbox
    3. Call your command from ABAP:
    data:
    param type sxpgcolist-parameters.
    status type extcmdexex-status,
    exitcode type extcmdexex-exitcode,
    it_log type table of btcxpm.
    p_src = '/common/home/edw/parsekb/b2/*'.
    p_dst = '/common/home/edw/parsekb/b1'.
    concatenate p_src p_dst into param separated by space.
      CALL FUNCTION 'SXPG_CALL_SYSTEM'
           EXPORTING
                COMMANDNAME                = 'Z_YOUR_COMMAND'
                ADDITIONAL_PARAMETERS      = param
           IMPORTING
                STATUS                     = status
                EXITCODE                   = exitcode
           TABLES
                EXEC_PROTOCOL              = it_log
           EXCEPTIONS
                NO_PERMISSION              = 1
                COMMAND_NOT_FOUND          = 2
                PARAMETERS_TOO_LONG        = 3
                SECURITY_RISK              = 4
                WRONG_CHECK_CALL_INTERFACE = 5
                PROGRAM_START_ERROR        = 6
                PROGRAM_TERMINATION_ERROR  = 7
                X_ERROR                    = 8
                PARAMETER_EXPECTED         = 9
                TOO_MANY_PARAMETERS        = 10
                ILLEGAL_COMMAND            = 11
                OTHERS                     = 99.
    if sy-subrc <> 0.
    *TODO: add your error handling logic
    endif.
    Regards,
    Maxim.

  • Call a unix command

    Hi Community,
    It's possible to create a program that a call does a unix command.
    I would like created a synchronous scenario.
    Then the program call a unix command and this is waiting up to when a unix command termined a runtime.
    The command returned a data and the ABAP program will owe to take back the esecution.
    I hope in you
    Thank's everybody.

    Hi Antonello,
    i'd do it with different job steps (SM36)
    1) Program1, which does a unix command:
    syntax:
      CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND
                    ID 'TAB'     FIELD TABL-SYS.´
    or have a look here: external commands
    2) Program2 handle the output (e.g. a file) of program 1
    regards Andreas

Maybe you are looking for