System command execution.

I know this will not make my program portable, but how can you execute system commands on windows xp, 2000, 98se, and *nix? Is there a class that will allow access to this?
I'm wanting to write a front end for cdrecord, and a few others.

Look at the various execute methods in Runtime.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
Also, you may want to read this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Similar Messages

  • System command execution from stored procedure

    Hello World,
    How to run System command from stored procedure ?
    For example :
    Delete a file
    running a programm,
    Is it possible ?
    H.M

    Years ago I did this by writing an output file with commands into a directory and had a cron job looking for this file. At the end of the run the file was removed.
    Never checked if there are other possibilities nowadays.
    cu
    Andreas

  • Problem in execution of Operating System Command

    Hi
    I am trying <b>OS command in Reciever File Adapter</b> but the command is not executing.In my scenario i am creating a file by reciever adapter and then this OS command will delete,rename..etc to this file.For this i had created a <b>Batch file</b> in which i had given OS commands, so once this batch file will execute the command should work.File is getting created but OS command is not executing.I am giving the command in the adapter as follows:
    <b>//Server-name/directory/Test.bat</b>
    i had tried giving command like this also
    <b>D:\directory\Test.bat</b>
    but there is no result.i read somewhere that this function works on SP9 or above.We are also working on SP9 but.....
    Do i have to make some settings for this function.
    If you have some solution then please help me.
    Thanx in advance.
    Regards
    Arpit Seth

    Hi,
    In help.sap.com (http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm), it is given as
    When the operating system command is called, the file name currently being processed can be specified with the following placeholders:
    · %f (file name)
    · %F(absolute file name including path)
    Are you using like this?
    rgds,
    Sasi

  • System commands - disk access

    To emulate the "clrscr" command (from C), I am determining the name of the OS and then passing the appropriate command to the Runtime object:
    if ((menu.osName.lastIndexOf("sun") != -1) || (menu.osName.lastIndexOf("inux") != -1))
      System.out.println("This is an unix terminal");
      menu.clearCommand = "/usr/bin/clear";
    else if (menu.osName.lastIndexOf("indow") != -1)
      System.out.println("This is a Windows MS-DOS terminal");
      menu.clearCommand = "C:\\Windows\\Command\\cls";
    else if (menu.osName.lastIndexOf("dos") != -1)
      System.out.println("This is a MS-DOS terminal");
      menu.clearCommand = "C:\\DOS\\cls";
    try
      menu.cls = Runtime.getRuntime().exec(menu.clearCommand);
      menu.cls.waitFor();
      menu.clsOut = new BufferedReader(new InputStreamReader(menu.cls.getInputStream()));
      while (menu.clsOut.ready())
        System.out.println(menu.clsOut.readLine());
      menu.clsOut.close();
    catch (Exception e)
    -However, I also want to make sure that the system command is not an alias for a malicious script, in terms of invoking any sort of IO (delete/create files, etc.). Is it possible to have some sort of wrapper mechanism around the execution of the system command to detect and catch any attempt to perform IO? So far, my application works as the code speaks out, but I am worried that the system command may not be what I expect.
    Thanks.
    --Ashwin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    What about making the information you need to clear the screen a part of the installation?
    You do
    clear >myclear.out
    cls >myclear.out
    or whatever and use the contents of the "clear screen" file from your Java program.
    Caveat however: under Unix you can have different types of terminal with different clear-screen sequences.
    Sometimes I ponder to make a request for a curses-like java package to give an API for such (more advanced, but still CUI-related) things. Or maybe there is such without my knowing it?

  • Problem with zip operating system command

    Hello,
    i have the following configuration in the file receiver adapter:
    Directory: /tmp/
    File Name Scheme: %name%.txt
    Variable substitution:
    Variable Name: name                 Reference: payload: record,1,name,1
    Run Operating system command:
    /usr/bin/zip /tmp/%f.zip %F
    The execution is succesful, but i have a small problem. The file name is "file.txt.zip", the .txt should appear but i dont know how to skip it, I have tried so many ways but it doesnt work, I should receive a file called "file.zip" With a file inside in txt format...
    Thanks,
    Luis

    Hi Sriram,
    Thanks, but that wouldnt work out, Im using the %f for my file name, so this move command shouldnt work for me, because my filename changes in every execution, so I cant write something like this: mv file.txt.zip file.zip
    The only solution I see would would be a command which deals with strings and that could remove the four last characters of "%f"..but I havent found anything for doing it.
    Regards,
    Luis

  • Run os system command

    Hello at all.
    I need an information.
    Exist a package that permit the execution of os system command into protect environment like UTL_FILE package that limit the action to the paths specified into utl_file_dir parameter ?
    Thanks
    Alessandro

    UTL_FILE_DIR is no longer the preferred usage.
    At the database level, the utl_file read/write path is better specified using a name of a Database Directory (created using CREATE DIRECTORY command) instead of the older ULT_FILE_DIR. This way, only oracle users granted the read/write permission to the database directory can use it.
    At the OS level, ensure that only required OS users have permission to read/write to the path. Normally. any files you create with utl_file will be automatically owned by the oracle software owner (usually oracle) because is is created by the oracle shadow process.

  • An unexpected error during Command execution

    Hi,
    I am using Project Server 2007 SP 2 at the moment. One of our user keeps encountering this error "An unexpected error during Command execution" for a project file.  We tried to restore the earlier version of the plan using Administrative restore.
    But it only works as a temporary fix as the problem keeps reapprearing. Kindly help.

    Only SP2 for Project 2007? Probably not worth trying to debug, with 2007 it is almost essential to have SP3 and the very last cumulative update for Project pro and Server. 2007 was a very buggy version (they were forced to release at same time as Office
    2007 and it was too soon).
    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

  • CCMS Auto-React: Operating System Commands

    Hi Gurus,
    I want to run an operating system command in the event that an alert is raised in my CEN CCMS system.
    I have set up the operating system command in SCEN (using SM69) and tested it -- no problems. I have used the example given on help.sap.com. It works great from SM69 or SM49.
    I have created a custom MTE Auto-Reaction Method that is a copy of the SAP standard and it points to the logical name of the op system command I created in SM69.
    But, when I assign the Auto-Reaction method to an MTE and kick off the auto-reaction, nothing happens. I have tried assigning it auto-reaction method as a method for a local MTE and also as a central auto-reaction, but I get nothing.
    Please help me see what I am missing.
    Many thanks in advance,
    Nic Doodson

    Hi Michael,
    Thanks for the response, I hope you can help.
    Logical command is called: Z_NI_ALERT_OVO
    It calls the operating system command: /usr/sap/tmp/test.sh
    It allows additional parameters.
    test.sh is :
    #!/usr/bin/sh
    echo $2 alert from $1 Message $5 $4 > /usr/sap/tmp/alert_$3.txt
    I can run this from SM49/SM69 and it works fine.
    Method is: Z_SEND_ALERT_TO_OVO
    Calls function module: SALO_EXECUTE_SYSTEM_COMMAND_V2
    Can be executed on: Any Server
    Execution Method: Periodically in Dialog Process
    Parameters:
    COMMAND : Z_NI_ALERT_OVO
    PARAMATERS : <blank>
    REACT_ON_ALERTS : red
    MTENAME : SID/SEGMENT/CONTEXT/OBJECT/ATTRIBUTE
    PARAMLIST_1: COLOR DATE_TIME MSG
    PARAMLIST_2: ID
    Help!
    I can only think there is something about it being a local/centrally distrubuted auto-reaction method...I'm assigning it as a cenrally distributed auto-reaction method.
    Any input would be great.
    Cheers,
    Nic

  • Appcmd.exe add backup Output message: ERROR ( hresult:80070002, message:Command execution failed.

    [04.01.2014 21:41:55.0743] [1] 0.  ErrorRecord: System.InvalidOperationException: Running the command 'C:\Windows\system32\inetsrv\appcmd.exe add backup IISBackup130408621156784845' failed. 
    Output message: ERROR ( hresult:80070002, message:Command execution failed.  
    The system cannot find the file specified.
    Error message:  
    Process exit code: 2.
    [04.01.2014 21:41:55.0746] [1] [ERROR] The following error was generated when "$error.Clear(); 
    configure-WSManIISHosting -EnableKerberosModule;
    " was run: "Running the command 'C:\Windows\system32\inetsrv\appcmd.exe add backup IISBackup130408621156784845' failed. 
    Output message: ERROR ( hresult:80070002, message:Command execution failed.  
    The system cannot find the file specified.
    Error message:  
    Process exit code: 2.".
    [04.01.2014 21:41:55.0746] [1] [ERROR] Running the command 'C:\Windows\system32\inetsrv\appcmd.exe add backup IISBackup130408621156784845' failed. 
    Output message: ERROR ( hresult:80070002, message:Command execution failed.  
    The system cannot find the file specified.
    BlatniS

    Try this instead in an Elevated PowerShell
    Import-Module WebAdministration
    Backup-WebConfiguration -Name MyIISBackup
    Robert Pearman SBS MVP
    itauthority.co.uk |
    Title(Required)
    Facebook |
    Twitter |
    Linked in |
    Google+

  • Calling Operating System Commands from PL/SQL using java

    Calling Operating System Commands from PL/SQL - The Java Way
    wlth help of given thread link,
    Calling OS Commands from Plsql
    but i had user privilege problem
    Declare
    x Varchar2(2000);
    Begin
    x := OSCommand_Run('/tmp/sri/GROUP_ho.sh');
    DBMS_OUTPUT.Put_Line(x);
    End;
    o/p;
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    i done the grant privillage also
    part
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    dbms_java.grant_permission('
    abcd', 'SYS:java.io.FilePermission','<<ALL FILES>>', 'execute');
    again
    get
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    same error;

    Process management at the OS level should prevent execution continuing in the calling code until the command has completed (either successfully or with error).
    If the low level java code were to spawn child process threads then execution could continue, but I'm guessing the Java function your talking about doesn't do that and just calls the operating system to execute the command and waits for the returning code to come back.

  • MDM Database command execution error. A SQL statement failed to execute

    Hi,
    When we tried to execute an MDM Java query modify/create, we get the following dump.
    Is this anything to do with the parameters that we pass or is it something to do with the database ?
    We have checked the code and we do not find anything wrong with the code at all.
    We are using Java API 5.5.63.73 and calling MDM API's using WebDynpro for Java.
    I have noticed this issue has been raised here as well :
    Database command execution error. (While mounting a repository)
    com.sap.mdm.commands.CommandException:
    com.sap.mdm.internal.protocol.manual.ServerException: Database command execution error. A SQL
    statement failed to execute. The actual error may have been written to a log file. at
    com.sap.mdm.data.commands.ModifyRecordCommand.execute(ModifyRecordCommand.java:163) at
    Regards,
    Subramanian V.
    Edited by: Subramanian Venkateswaran on Dec 10, 2008 8:11 PM

    Hi Subramanian  ,
    The error looks more like a problem with the data base or MDM system rather than the java code.
    Which is the underlying database you are using with MDM? As some users have faced some difficulties when working with the DB2 Data base,If this is the data base you too are working upon then may be the issue could be similar,if possible try using the Oracle or SQL data base as these databse show more compatibility than a DB2 when working with MDM .
    Also check the MDM users autorization and authentication to modifyor create recordrs in MDM.try given the user the ADMIN rights,and tehn try and see if teh user is able to modify/Create the mdm records.
    Lastly you can check the database instance and listener configuration correctly.try restarting the Database service form the system if possible.
    Hope It Helped
    Thanks & Regards
    Simona Pinto

  • Mysqldump command execution in java

    public class SqlDum
    public static void main(String args[])
    try
    String str="mysqldump -u root -p threadpool > test.sql";
    Process p=Runtime.getRuntime().exec(str);
    p.waitFor();
    catch(Exception e)
    System.out.println(e);
    }The above code executed sucessfully but there is no generation of sql file.If iam run the command mysqldump -u root -p threadpool > test.sql its executes sucessfully and backup file created.... Command execution takes place in linux platform...?how can i execute in java?

    hi friends,can anyone tell me the way to do backup of
    my database in MySql.Iam already shown my program....
    anyone tell me the changes what i do in that
    program?iam using that program in linux
    platform...?can anyone tell me the solution or
    suggestion... thanks in advanceCome on man! Wake up!
    READ THIS this -> http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    AND NOTE WHAT "it says there about output redirection"
    Okey buddy?

  • Urgent!! running system command in java

    i am trying to run system command(windows) in java. I am getting
    exception as java.io.IOException: CreateProcess: c:\dir
    Please Help.
    Here is the code
    import java.io.*;
    public class RunCommand {
    public static void main(String[] args) {
    try
    //run dir command
    Process p = Runtime.getRuntime().exec("c:\\dir");
    BufferedReader stdInput=new BufferedReader(new
    InputStreamReader(p.getInputStream()));
    BufferedReader stdError =new BufferedReader(new
    InputStreamReader(p.getErrorStream()));
    //read the output
    System.out.println("here is the output:\n");
    while((s=stdInput.readLine())!=null){
    System.out.println(s);
    System.out.println("here is the error if any");
    while((s=stdError.readLine())!=null){
    System.out.println(s);
    System.exit(0);
    }//end try
    catch (IOException e)
    System.out.println("exception Happened" );
    e.printStackTrace();
    System.exit(-1);

    It works fine if you replaceProcess p = Runtime.getRuntime().exec("c:\\dir");withProcess p = Runtime.getRuntime().exec("cmd /c dir");And don't forget to define your s variable.

  • How to Run Operating System Command Before/After Message Processing SAP PI

    Hi,
    We are trying to execute multiple commands via "Operating System Command Before/After Message Processing".
    When we use single command say for example cp or mv (copy or move) the commands get executed fine.
    eg: cp %F /var/opt/data/outbound/Test/Dummy.txt 
    /this works fine/
    when we club commands together or try to redirect the outputs of commands, none of the commands get executed.
    eg:
    cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
    or
    wc -l %F > /var/opt/data/outbound/Test/Dummy.txt
    Is it possible to execute multiple commands or redirect the output  of commands without using a shell script? The PI server we are working on iis hosted on UNIX environment.

    Hi Harleen,
    try like this
    cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
    instead of semicolon try this
    (1) &
    command1 & command2
    Execute Command1 and then execute Command2
    (2) &&
    command1 && command2
    Runs the command2 only when command1 doesn't Complete successfully
    (3) ||
    command1 || command2
    Runs the second command if the first command had an error
    (4) ()
    (command1 || command2) || (command3 & command4)
    Defines the order in which commands are to be executed
    Regards
    Suraj

  • Dual Boot - Solaris 8 intel under system commander

    I am interesting in installing Solaris 8 for intel on my PC but need to keep my existing operating environments (98 and NT). I would like to install solaris on either a spare partition or spare disk drive.
    Has anyone managed to configure solaris 8 to boot from system commander deluxe. I know it is possible with Solaris 7 but I have no documentation on for Solaris 8. I cant seem to get through to the System Commander people.

    hi phil_xxx
    I am using a dell dimension 4100 machine. I already have win200,win98 in the primary drive(10GB) using using 'System Commander' as boot manager to select the OS( to boot into).
    I installed slave disk(30GB-IBM)and have been trying with all the possibilities to get the solaris(version-6/00)installed on the slave disk. I used "Solaris 8 Software 1/2" CD. I was not able to get solaris installed on second(slave) disk evenwitth the single user mode.
    Looking for ur help badly if u have got any result.
    -Nalla ([email protected])

Maybe you are looking for

  • Unable to load Database Error for one of the BSO Application.

    Hello Everyone, We have one Production Issue like suddenly the an Application Fiji while should be running was stopped. When i tried to restart it its showing Error. gvw3086-v.atlanta.hp.com:1423.Fiji    Start  application    August 28, 2013 8:32:24

  • After upgrading to 10.6 I cannot use AppleTalk to connect to my HP LaserJet 4ML printer.

    After upgrading to 10.6 I can no longer use AppleTalk to connect to my HP LaserJet 4ML printer. So I am now using a JetDirect 300X box connected to the parallel port of the printer and an ethernet cable into my Linksys router. But I have had no luck

  • Update query using FORALL statement

    Hi ALL, I have two tables Table: Mater_A(20 Cloumns) and Temp_A(20 Columns). Both are almost identical. The Master_A is master table that has to be updated daily based on the temporary table Temp_A. Everyday , i expect around 100000 records(same reco

  • SHA-1 Encryption of passwords

    I believe that in Netweaver 6.4 and above SHA-1 is used for password encryption.  Does anyone know if a 'salt' is used when encrypting?  If not, can use of a 'salt' be configured, and also verified?  Thanks in advance.

  • Mac Book Pro Running Slow since installing Mountain Lion

    Since I downloaded Mountain lion this summer my MAc Bok has been running slow and running hot.  I am not sure what to do.  I checked my hard drive is only 4GB and I may need to upgrade it.  But waht else can I do? Saran