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.

Similar Messages

  • Having trouble in running a unix command and getting the output

    Hi,
    I am trying to run a unix command from within the java code. I am not able to make it work. I am enclosing the code and the error message that I am getting. Any help is highly appreciated.
    import java.io.*;
    public class RunCommand {
        public static void main(String args[]) {
            String s = null;
            try {
                Process p = Runtime.getRuntime().exec("cat UNIX_ASCII_TEXT_FILE | A_UNIX_PROGRAM -d");
                BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
                // read the output from the command
                System.out.println("Here is the standard output of the command:\n");
                while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
                // read any errors from the attempted command
                System.out.println("Here is the standard error of the command (if any):\n");
                while ((s = stdError.readLine()) != null) {
                    System.out.println(s);
                System.exit(0);
            catch (IOException e) {
                System.out.println("exception happened - here's what I know: ");
                e.printStackTrace();
                System.exit(-1);
    }The error message that I am getting is
    Here is the standard output of the command:
    SLu|%%$$=
    Here is the standard error of the command (if any):
    cat: cannot open |
    cat: cannot open A_UNIX_PROGRAM
    cat: cannot open -dLooks like the cat command is working and not the pipe command and the command after the pipe. But when I run the UNIX command from the command prompt I get the expected result.

    You might read this article and see if its approach works.
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Learning Unix commands (and automator/applescript) for a dummy :-)

    Hi:
    I've been supporting macs for many years and have done mostly user end support with all the various GUI tools. I've never been a programmer, never had the mind for it, etc.
    However, I've now reached the point where I need to do some kind of scripting and I'm looking for some good learning/training tools. I was wondering if anyone might have suggestions about the best training / reference guides to go about doing this. Right now, it's as if I need to play a little Beethoven, haven't learned Chopsticks yet and I'm trying to find out how to play chopsticks while learning a little Beethoven at the same time. (how's that for a metaphor?)
    For example: For my first project, I have to set up a backup for some laptop users so that certain files will be backed up. The need is different for each user, so this is why setting up a script would be easiest. My goals in the setting up this project are:
    - Make the script run at logout (logout hook)
    - check to make sure the network volume I want to backup to is present; if not present, stop the script
    - Use either cp or rsync to copy the files/directories to the shared volume.
    I've tried to look around the internet for help, examples, etc, but I've been unable to put together exactly the commands I need to sue to accomplish my task.
    Any suggestions would be great.
    Thanks!

    If you already know something about unix commands, there is a scripting tutorial at http://www.tldp.org/LDP/abs/html/index.html
    If you need a tutorial on unix commands, http://osxfaq.com/Tutorials/LearningCenter/UnixTutorials/LoseTheMouse/index.ws had a pretty good tutorial, although at the moment, that link isn't loading for me now so I don't know if it is still up online or not.
    for creating logout hooks, http://www.bombich.com/mactips/loginhooks.html might help.
    Also, in Terminal, type man launchd.plist if you can think of a scenario where you could implement a "cron-like" solution. Then refer to Apple's own periodic daily/weekly/monthly launchd plists (com.apple.periodic-*ly.plist) at/System/Library/LaunchDaemons/. There are more triggers available than just day/date/time, such as "watchPaths" and "RunAtLoad." Home grown launchd plists ones should go in /Library/LaunchDaemons/ or Library/LaunchAgents, not /System/Library/LaunchDaemons/. Also man launchd (no ".plist").

  • Running Unix commands and scripts from HTML-DB

    Hi,
    How can I run scripts (like perl scripts) that I have on the UNIX machine that the HTML_DB is installed on.
    How for a start can I run even simple UNIX command like "ls" ?
    Thanx,
    Alon

    Alon,
    Best to try the database forum and search for "external process" or "extproc" for this - it needs setup for the listener and in the database itself.
    You need to be aware - all your commands will be run as the oracle user so you should be very careful who can run them and what commands they can run.
    Greg

  • How to execute unix command through odi and store the result in table

    I have to reconcile  if data is loaded in table from csv file or not . I have to create a oracle data integrator package/interface/procedure to execute unix command to count number of rows in the csv files and store the count result in a table then i have to query the loaded table and count number of rows there and store in the table and have to compare is counts are same or not,  Please assist me how to make package/interface/procedure to  execute unix command and store result in oracle table.
    Thanks in Advance

    Use ODI OS command tool in the ODI package.
    create an interface in ODI using LKM File to Sql and the output file generated with the csv file's row count as a source and the db table(where the count needs to be stored) as a target

  • URGENT!! problems with Unix command, please help

    I am trying to use the following Unix command and I keep getting error messaages from stdError. However if I run the same command from the command line it works perfectly. For some reason when I run the command from inside the program it thinks the append symbol ">>" is another file.
    String command = " cat /users/02/wjoc1/Test/list.mod >> /users/02/wjoc1/Test/Blacklist ";
    Process p = Runtime.getRuntime().exec(command);
    The error get is :
    /bin/cat: >>: No such file or directory
    Any help would be greatly appreciated

    The better solution for this problem is write a shell script for the action you wnat to perform and execute it using the runtime.exec().In your case just cut and paste cat /users/02/wjoc1/Test/list.mod >> /users/02/wjoc1/Test/Blacklist in to a file and save it. use that file as a argument for the exec method it will work.
    cheers
    R.Karuna

  • Is there an ARD command or Unix command that I can send to reset the desktop background image to default?

    I was forced to create a local user with an automatic login on all of the machines in the building. I listed off many various issues that could come arise by doing this but was tuned out. Now people are changing all of the desktop backgrounds to some pretty inappropriate images. I forewarned the person ordering this that this may be one of the many issues that would arise when doing away with our server based logins, and now I am charged with fixing every desktop every time someone changes it to something inappropriate.
    Is that an Apple Remote Desktop command or a Unix command that I can send through ARD v3.5.3 to the machines to reset the desktop background image to the default Aqua Blue jpeg image located in the /MacintoshHD/Library/Desktop\ Pictures/Aqua\ Blue.jpg.
    The machines that I am dealing with have OS X 10.4.11, OS X 10.5.8, OS X 10.6.8, and OS X 10.7.4 installed on them, but the OS X 10.4.11 machines are the ones that are creating the biggest issue so I would like to deal with those first.

    Ya, I'd love to have the computers connected to the Xserver, unfortunately against my heeding, I was ordered to take them off of the Xserver, so they only have a local account that automatically logs in on startup, and even though I have Parental Controls set, I can not stop them from going to Safari, selecting an inappropriate image and setting it as the background, so now I’ve been ordered to fix all of the backgrounds that people are messing with.
    My Xserver is running OS X 10.4.11 Server Edition. Yes, I would love a new server, but that’s not happening due to budget cuts.
    So what I am hoping for is a command that I can put into Apple Remote Desktop v3.5.3 and push out to all of the computers via its Unix commands and reset all the desktops to their default image.

  • 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

  • Run Unix command from windows

    I would like to run a unix command and capture the output by running a java program on a windows 98 machine, this will be ran on a secure intranet. What is the best way to do that. If anyone knows of an example source code that would be great.
    thanks,
    Dean

    Try this. It always works for me.
    import java.io.*;
    public class Exec {
        private BufferedReader out;
        private Process p;
        public Exec(String cmd) throws IOException {
            p = Runtime.getRuntime().exec(cmd);
            out = new BufferedReader(new InputStreamReader(p.getInputStream()));
        public BufferedReader getBufferedReader() {
            return out;
        public void waitFor() throws InterruptedException {
            p.waitFor();
        public static void main(String [] args) throws IOException,
                InterruptedException {
            final Exec p = new Exec("your command goes here.");
            new Thread(new Runnable() {
                public void run() {
                    try {
                        String s = null;
                        while((s = p.getBufferedReader().readLine()) != null) {
                            System.out.println(s);
                    catch(IOException io){}
            }).start();
            p.waitFor();
    }

  • Permission denied when I execute a unix command from within my java applet.

    Hi Gang,
    Forgive me if this is not the appropriate forum for this problem. I'm posting this problem on this forum since I got no answers on the other forum I posted on.
    I've written a simple java applet that runs a unix command and then displays some information. The applet compiles fine, and runs perfectly from the command line on my unix system.
    However, when I point a browser at the applet from my desktop PC I get the following error as taken from the java console:
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
    This is of course the first line in a long line of error messages. It appears that I am not able to execute a command on the unix system through my applet. I know the problem is with trying to execute a unix command since commenting it causes no error in the web browser. This is the command I'm using in java to execute the unix command:
    p = Runtime.getRuntime().exec("ps");
    Here's the html file on the unix system:
    <html>
    <head></head>
    <body>
    <appletcode=G.class height="250" width="400">
    Your browser does not support the applet tag.
    </applet>
    </body>
    </html>
    I won't list the java code since it is compiling and working on the command line. But, if you want to see it I'll provide it.
    I've done quite a bit of research on this and it seems that a great number of people have similar problems reading or executing files through java. I have yet to find a solution to this problem.
    Here are some details about my setup:
    Server:
    HP9000 running HP/UX 11.23
    Apache Web Server 2.0.35
    Java 1.5
    Desktop PC:
    Win2K Pro
    Internet Explorer 6
    Java 1.6
    If you have a solution I would be very grateful! This problem is keeping me from writing my application!
    thanks!
    kev

    Multi-posted.
    Already answered here http://forum.java.sun.com/thread.jspa?threadID=5225314&messageID=9916327#9916327

  • Permission denied when I execute a unix command from inside my Java applet.

    Hi Gang,
    Forgive me if I'm posting this to the wrong forum! I didn't get any answers on the previous forum that I posted this to.
    I've written a simple java applet that runs a unix command and then displays some information. The applet compiles fine, and runs perfectly from the command line on my unix system.
    However, when I point a browser at the applet from my desktop PC I get the following error as taken from the java console:
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
    This is of course the first line in a long line of error messages. It appears that I am not able to execute a command on the unix system through my applet. I know the problem is with trying to execute a unix command since commenting it causes no error in the web browser. This is the command I'm using in java to execute the unix command:
    p = Runtime.getRuntime().exec("ps");
    Here's the html file on the unix system:
    <html>
    <head></head>
    <body>
    <appletcode=G.class height="250" width="400">
    Your browser does not support the applet tag.
    </applet>
    </body>
    </html>
    I won't list the java code since it is compiling and working on the command line. But, if you want to see it I'll provide it.
    I've done quite a bit of research on this and it seems that a great number of people have similar problems reading or executing files through java. I have yet to find a solution to this problem.
    Here are some details about my setup:
    Server:
    HP9000 running HP/UX 11.23
    Apache Web Server 2.0.35
    Java 1.5
    Desktop PC:
    Win2K Pro
    Internet Explorer 6
    Java 1.6
    If you have a solution I would be very grateful! This problem is keeping me from writing my application!
    thanks!
    kev

    Multi-posted.
    Already answered here http://forum.java.sun.com/thread.jspa?threadID=5225314&messageID=9916327#9916327

  • ARD 3.6.1 remote log in Unix command failure

    Hello, I am using 10.7.5 and ARD 3.6.1 and cannot figure out how to remotely log in to another computer
    I wish to remotely log in using ARD to multiple computers in my network, up to 30 at a time for elementary students.  I can observe, control and send Unix commands to the machines when they are at startup log in screen or in use. This is the Unix command I am trying to use to log into the comptuer using ARD and Unix command function.
    osascript -e 'tell application "System Events" to keystroke "login"'; \
    osascript -e 'tell application "System Events" to keystroke tab'; \
    osascript -e 'tell application "System Events" to delay 0.5'; \
    osascript -e 'tell application "System Events" to keystroke "password"'; \
    osascript -e 'tell application "System Events" to delay 0.5'; \
    osascript -e 'tell application "System Events" to keystroke return'
    **and yes I am changing the login and password keystroke**
    I have tried the above Unix command and several others but I get a message saying "A console user is not logged in on “studnetmacbook""  so I click the button to run command as user admin but then get the message below. 
    36:50: execution error: An error of type -10810 has occurred. (-10810)
    36:49: execution error: An error of type -10810 has occurred. (-10810)
    36:54: execution error: An error of type -10810 has occurred. (-10810)
    36:52: execution error: An error of type -10810 has occurred. (-10810)
    36:52: execution error: An error of type -10810 has occurred. (-10810)
    Could someone explain these errors.  Is ARD not compatible with remote log in with the versions I have?  I have seen on sites this is posted and other sites that this needs to be run as the root user...Should I know how to run this as a root user and if so could someone help me with how to do this? 
    Or if anyone else has a working command could you share it with me for remotely logging in using ARD.
    Thanks!

    Hi
    Don't quite recognise what it is you're using. Maybe try:
    osascript <<EOF
    tell application "System Events"
    keystroke "whateverusernameyou'reusing"
    keystroke tab
    delay 0.5
    keystroke "whateverthepasswordis"
    delay 0.5
    keystroke return
    end tell
    EOF
    Instead. Works every time for me.
    The above are all on separate lines.
    HTH?
    Tony

  • How does one execute unix commands from within an applet?

    Greetings Folks,
    I've written a simple java applet that runs a unix command and then displays some information. The applet compiles fine, and runs perfectly from the command line on my unix system.
    However, when I point a browser at the applet from my desktop PC I get the following error as taken from the java console:
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
    This is of course the first line in a long line of error messages. It appears that I am not able to execute a command on the unix system through my applet. I know the problem is with trying to execute a unix command since commenting it causes no error in the web browser. This is the command I'm using in java to execute the unix command:
    p = Runtime.getRuntime().exec("ps");
    Here's the html file on the unix system:
    <html>
    <head></head>
    <body>
    <appletcode=G.class height="250" width="400">
    Your browser does not support the applet tag.
    </applet>
    </body>
    </html>
    I won't list the java code since it is compiling and working on the command line. But, if you want to see it I'll provide it.
    I've done quite a bit of research on this and it seems that a great number of people have similar problems reading or executing files through java. I have yet to find a solution to this problem.
    Here are some details about my setup:
    Server:
    HP9000 running HP/UX 11.23
    Apache Web Server 2.0.35
    Java 1.5
    Desktop PC:
    Win2K Pro
    Internet Explorer 6
    Java 1.6
    If you have a solution I would be very grateful! This problem is keeping me from writing my application!
    thanks!
    kev

    Multi-posted.
    Already answered here http://forum.java.sun.com/thread.jspa?threadID=5225314&messageID=9916327#9916327
    Please don't multipost again!

  • Run adobe cs3 updater remotely via command line unix command?

    is there a way to run the adobe updater from the command line for adobe cs3? I have a bunch of machines that already have cs3 installed, and I would like to be able to use ARD to "send unix command" and have the installer run and update the relevant apps?
    Thanks in advance...
    PS-is it me or is this forum ridiculously slow on safari? Sheesh!

    is there a way to run the adobe updater from the command line for adobe cs3? I have a bunch of machines that already have cs3 installed, and I would like to be able to use ARD to "send unix command" and have the installer run and update the relevant apps?
    Thanks in advance...
    PS-is it me or is this forum ridiculously slow on safari? Sheesh!

  • Run Unix command / Run Unix shell script from Forms9i

    Hi,
    I have a requirement to run Unix command and Unix shell scripts from Forms9i.
    I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
    Please point me towards any other way to achieve the same.
    I would really appreciate your help.
    Thanks,
    Kumar

    There is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
    The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands.

Maybe you are looking for

  • Why to implement e-commerce gateway?

    Hi All, We are in process of finalization of whether we should Tibco route or e-commerce route for the inbound and outbound transations. My understanding of E-Commerce Gateway is :- It takes the flat file provide by EDI translator(X12 format) and pus

  • How can I modify the logon screen on the portal

    Hi, We have designed some BI queries, when we open Query Designer and execute them (CTRL + R) an Internet Explorer open and ask us to log on this BI Portal. On this Portal login screen, I can only provide my user name and password. We would like the

  • Different versions of 10.5.4

    This may seem silly what is the difference in 10.5.4 update and the 10.5.4 combo update other than the size of the file. JJ

  • PB doesn't always start up/won't run on charged battery

    I have a 15" aluminum PowerBook that I've slowly been bringing back to life after it had a full mug of coffee dumped into it. I cleaned everything out and it's working again, for the most part. However, there are a couple of unresolved problems. The

  • Jndi.properties?  where?

    This is a stupid question but I cant quite figure out a good location for jndi.properties. Where would be a good place to load this file so that it is only available from within a specific application. Thanks, Jeff