Application Development and Automation 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: 
Read only

executing dos command

Former Member
0 Likes
2,096

Hi experts

I have this scenario.

<b>I have to ping to a server and get the result into a file.</b>

<b>1.</b>I tried with dsvas_doc_ws_execute_50 in se37 directly but no response only c:\programfiles poped up. Any idea on what i should do with this function module.

<b>2.</b>I am not aurthorized to use SXPG_COMMAND_EXECUTE.

Try from ur side and What will the result if do this se37

COMMANDNAME ping

ADDITIONAL_PARAMETERS xxxxxx

OPERATINGSYSTEM windows nt

TARGETSYSTEM application server ip

DESTINATION don know what to give. try giving a

file path and try to upload any file.

all worthy replies will be appriciated.

don give any link as an answer.

<b>try it out on ur side and let me know.</b>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,237
CALL METHOD cl_gui_frontend_services=>execute
  EXPORTING
*    DOCUMENT               =
    application            = 'CMD.EXE'
    parameter              = 'ping ip'
*    DEFAULT_DIRECTORY      =
    MAXIMIZED              =  'X'
*    MINIMIZED              =
*    SYNCHRONOUS            =
*    OPERATION              = 'OPEN'
  EXCEPTIONS
    cntl_error             = 1
    error_no_gui           = 2
    bad_parameter          = 3
    file_not_found         = 4
    path_not_found         = 5
    file_extension_unknown = 6
    error_execute_failed   = 7
    synchronous_failed     = 8
    not_supported_by_gui   = 9
    OTHERS                 = 10
        .
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Message was edited by: Vijay Babu Dudla

8 REPLIES 8
Read only

Former Member
0 Likes
1,238
CALL METHOD cl_gui_frontend_services=>execute
  EXPORTING
*    DOCUMENT               =
    application            = 'CMD.EXE'
    parameter              = 'ping ip'
*    DEFAULT_DIRECTORY      =
    MAXIMIZED              =  'X'
*    MINIMIZED              =
*    SYNCHRONOUS            =
*    OPERATION              = 'OPEN'
  EXCEPTIONS
    cntl_error             = 1
    error_no_gui           = 2
    bad_parameter          = 3
    file_not_found         = 4
    path_not_found         = 5
    file_extension_unknown = 6
    error_execute_failed   = 7
    synchronous_failed     = 8
    not_supported_by_gui   = 9
    OTHERS                 = 10
        .
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Message was edited by: Vijay Babu Dudla

Read only

0 Likes
1,237

sorry vijay babu

My abap version does not support cl_gui_frontend_services.

Read only

0 Likes
1,237

Hi,

what is with:

- abap RSRFCPIN

- fm RFC_PING

Andreas

Read only

Former Member
0 Likes
1,237

Hi vijayasarathy,

1. The FM is right.

But definitely u must have rights

for executing OS command.

(ur basis team might help u)

2. Secondly, ur applciation server

must be window based (i suppose)

for ping.exe

3. In SM69 a new command must be there

where the command name should be PING.

4. U can execute the command thru FM

and pass parameters.

machinename > d:\abc.txt

so that the output of PING command gets into

a text file.

5. Ater that u need to fetch the info from file

using DATASET.

I hope it helps.

regards,

amit m.

Read only

0 Likes
1,237

Hi amit

basically i don have the basis rights.

Any way tell me about FM gui_exec.

what can be don with that.

Read only

0 Likes
1,237

Hi again,

1. u are right. One way is that

we can us the FM GUI_EXEC.

2. This will execute OS command

on the front-end (And not on app server)

(So we assume that ping.exe is on the front-end

server and its a window based system)

3. In the FM

there is a parameter COMMAND.

in that just pass:

CMD /C PING computername > D:\DEF.TXT

[ Pls note that just using PING will not work.

We also have to use CMD along with PING ]

4. It will do what u require.

5. I just tried at my end and it works fantastic.

I hope it helps.

Regards,

amit m.

Read only

0 Likes
1,237

Hi

I amit i tried same way as u did but it did not work for me.

Also what is the difference in execute in front end and on application server.

Can u send ur screen shots to this mail id.

<b>rvjoy_sarathy@yahoo.co.in.</b>

regrads

vijay

Read only

0 Likes
1,237

Hi again,

1.what is the difference in execute in front end and on application server

a) the pc u are working on is called the

front-end.

b) The R/3 instance running on the server.

That server is called application server.

2. Accessing files on both these computers.

(ie front-end local pc, and server)

cannot be done in just 1 way.

There are 2 different methods.

3. I assume that u are working on a computer

having windows operating system

(98, XP, windows 2000 etc.

Bcos it will have ping .exe)

4. Goto SE37

5. Execute the FM GUI_EXEC

6. In the COMMAND parameter, type

cmd /c ping computername > d:\def.txt

7. Please note that

computername is the computer u want to ping.

d:\def.txt is the file where u want the results

of the ping command.

8. Now EXECUTE the FM

9 A Black Window (DOS Prompt window )

will appear for 3 - 5 seconds

and disappear thereafter.

10. Goto your director d:\ (as mentioned in the parameter)

and check the file

def.txt

11. It works fantastic.

I hope it helps.

regards,

amit m.