SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

UNIX command on application server and view the output



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Connect to External system, Unix и Perl
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 15, 2007 9:02 pm    Post subject: UNIX command on application server and view the output Reply with quote

Issue an UNIX command on application server and view the output or diagnostic messages.

Code:
report z_unix_command.
* 1. delay after unix command to complete standard & diagnostic output
* (time to executing) = 4 seconds:
constants:  c_time     type i value 4000000. "in microseconds
types:      t_cmd(255) type c,               "Unix Command with Args etc
            t_it       type t_cmd occurs 0.  "Table of Information
************************************************************************
constants:
*---- file names (output and diagnostic)
c_log      type t_cmd value '/tmp/sgicsbinipivvva',
c_diag     type t_cmd value '/tmp/soisisdinipivvva',
*---- UNIX commands redirectors.
u_gt       type t_cmd value '>',
u_2gt      type t_cmd value '2>'.
************************************************************************
parameters  p_cmd type t_cmd default 'date' obligatory lower case.
************************************************************************
data:       w_cmd       type t_cmd,     "Unix command with redirection
            it_log      type t_it with header line,  "Output
            it_diag     type t_it with header line.  "Diagnostic

************************************************************************
end-of-selection.
  perform unix_command using p_cmd.

************************************************************************
form read_file tables p_it type t_it
               using value(p_file) type t_cmd.
  data w_msg(50).
*--- open UNIX file
  open dataset p_file for input in text mode message w_msg.
  if sy-subrc ne 0.
    write: / 'Cannot open for reading:', p_file, w_msg.
    exit.
  endif.
*--- read UNIX file
  clear: p_it, p_it[].
  do.
    read dataset p_file into p_it.
    if sy-subrc = 0. append p_it.
    else.            exit.
    endif.
  enddo.
*--- close UNIX file
  close dataset p_file.
endform.
************************************************************************
form unix_command using value(p_cmd) type t_cmd.
  data:     w_time  type i,
            w_start type i.
  write p_cmd.
  concatenate p_cmd u_gt c_log u_2gt c_diag
              into w_cmd separated by space.
  call 'SYSTEM' id 'COMMAND' field w_cmd.
  clear: it_diag, it_diag[], it_log , it_log[].
  get run time field w_time.
  w_start = w_time.
  do.
    get run time field w_time.
    subtract w_start from w_time.
    if w_time > c_time.
      exit.
    endif.
    perform read_file tables it_diag using c_diag.
    perform read_file tables it_log  using c_log.
  enddo.
  loop at it_diag.
    write / it_diag color col_negative intensified off.
  endloop.
  loop at it_log.
    write / it_log color col_positive intensified off.
  endloop.
endform.
************************************************************************


Source: http://www.geocities.com/victorav15/sapr3/utilities/system.txt
Back to top
View user's profile Send private message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Wed Jul 20, 2011 3:23 pm    Post subject: Reply with quote

Code:
data: unixcmd(100) type c.

unixcmd = '/directory/application.exe'.

* Executing the system commands witin ABAP.
CALL 'SYSTEM' ID 'COMMAND' FIELD unixcmd.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Connect to External system, Unix и Perl All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.