Runtime.exec(" find . -name *.txt -exec rm {} \; ") don't work why?

Hi,
I have to exec a unix command like " find . -name *.txt -exec rm {} \; " in a java program, but it don't work fine because of option -exec.
The source is :
String line="",lineErr="",comando="";
try
comando=" find . -name *.txt -exec rm {} \; ";
process = IstanzaRuntime.exec(comando);
inStream = process.getInputStream();
errStream = process.getErrorStream();
There are problems only in commands with options like -exec that permit to exec 2 commands in one .
There is another way to write the command?
Thanks in advance
Lorenzo

1. you have to use quotes around *.txt
i.e \"*.txt\"
or '*.txt'
depending how you are calling the command.
2. the directory should be specified otherwise you will be deletinfg files from the USER HOME directory.
find . = find /USERHOME
find ./mydir = find /USERHOME/mydir
find /usr/tmp/mytmpdir = find /usr/tmp/mytmpdir (i.e root stem).
3. the {} should not be a problem.

Similar Messages

  • Finder methods that return collections (don't work)

    Hi all, this looks like an internal error, but I though Id ask incase there is a way around it.
    Im having some problems with entity java beans using jdeveloper and the internal j2ee server. The bean is deployed and runs, find by primary key and all other methods work except find by last name which returns a collection.
    I have experimented with the code, and stepped through with the debugger. The debugger doesn't find any errors or throw any exceptions. The method which it calims causes the error ejb find by last name does not throw an error and exits normally.
    Though experiments I have done I have found that the failure only occurs if the collection returned has elements. If and empty collection is returned then the error is not given. If null is returned then the same error is given with a null pointer exception at the start instead of class cast. I have tried serveral variations on this code and none seem to work. Im hoping this is a common bug and you can point me towards a solution.
    I have browsed your forum and searched your site, as well as the web for information on this bug but have not found any information.
    My OS is Linux Red Hat 8.0 and the version of JDeveloper is 9.0.2.8.2. I urgenly need assistance with this, it forms the basis for a final year degree project which needs to be submitted in 4 weeks.
    -- Error output --
    java.lang.ClassCastException: java.lang.Integer
         at com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMIConnection.java:1530)
         at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:1453)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:53)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:22)
         at __Proxy0.findByLastName(Unknown Source)
         at SamplepodPackage.PatientClient.main(PatientClient.java:88)
    -- output ends --
    Thanks for your time
    Glenn Jenkins
    (Glamorgan University)

    I think I've figured it out. I checked my keywords and some of the keywords I used were unintentionally under another keyword, so it appears that smart collections useingn using child keywords will always include the parent keyword, even if that keyword isn't listed in the Keyword panel. When I moved the wrong children outside the existing parent, the Smart Collection worked properly. Now I have to figure out how the keywords unintentionally became children to other keywords.
    CPB
    CPB
    Craig P. Beyers
    703-626-3848 (m)

  • System Exec+ "CMD /C START DESK.CPL" won't work--why?

    I've seen previous posts stating that the System Exec is the equivalent of the run box in windows (explaining why you can't execute commands like "dir").
    However, I can run a line like this...
    CMD /C START C:\WINNT\SYSTEM32\DESK.CPL
    or
    CMD /C START C:\WINNT\SYSTEM32\NIPORTS.CPL
    ..from the run menu, but not with System Exec+. CPL files of course are executables that load in the control panel and a WinNT shortcut will not show you the path.
    The workaround is to create a batch file on the fly and execute the text above (since porting the application to a different computer means there might not be an existing batch file). The batch file looks like:
    @CMD /C START C:\WINNT\SYSTEM32\DESK.CPL
    @EXIT
    I don't like having to generate a batch file inasmuch as it does get the job done, there is still the clunky dos box that flashes onto the screen for a brief second. Does anyone know what causes the above discrepancy? ...why it will run from the windows run box, but not with System Exec+? I'm guessing it has something to do with using the START command but I have never had to use it before in this fashion. Any ideas?

    Arg! You're right!
    I originally tried this with NIPORTS.CPL and used DESK.CPL in the above example (without testing it) because everyone has desktop properties but not necessarily the port properties for the E-NET/RS-485 converter. I'm guessing there was a spelling or path error somewhere that wouldn't let my original attempt execute--it works now.
    Also: I didn't realize that any time you execute CMD that it will show a dos box, not just for batch files. Oh well...
    Thanks for your input...

  • I have a 2013 iMac and adobe flash and reader don't work, why.

    I cannot open PDF's and adobe flash does not work what can I do?

    I have ordered a 27inch late 2012 but your questions is puzzling.  The pdf viewer is built into "quick look" and finder can even display thumbnails of pdf documents.  Did you download a pdf viewer from adobe?  Is a different program now set to be the default for opening pdfs?  When you got the computer did you setup or migrate from an existing mac?
    If you right click or command-click on a pdf, what are the options to view it?

  • Games don't work, why wasn't it obvious

    I purchased a game on iTunes, and then found out my iPod Mini won't play it. There was no warning to me during my purchase, which really stinks. Now what?

    Right at the top of the games page is this warning.
    If you purchased a game for an unsupported iPod, you may ask for a refund using this email form.
    iPod Games Customer Support.
    Please bear in mind that any refunds will be at Apple's discretion.

  • Commit work and wait don't work,why

    Hi All,
    I call BAPI 'BAPI_PO_CREATE1' and create PO, then commit via
    commit work and wait.
    after creating, query the new PO via
    SELECT ebelp pstyp INTO TABLE lt_ebelp
      FROM ekpo
      WHERE ebeln = p_lv_ebeln.
    but no result.
    If creating and waiting a moment, it do work.
    why, I already used 'commit work and wait' but not 'commit work'.
    thanks.
    regards.
    dou

    Okay ,first check whether po number is getting saved or not .
    If po is saving then use BAPI_TRANSACTION_COMIITT FM ..
    Now check ur select query like : Since wait upto n seconds ( This may not work)
    data : n Type i.
    n = 10.
    write the below code after  BAPI_TRANSACTIOn_COMITT.
    do n times.
    select query
    if sy-subrc eq 0.
    exit.
    endif.
    enddo.
    still document number is not coming ,testing purpose increate n as 20 and see the results.
    Thanks
    Seshu

  • Actions; how do I find what commands don't work in actions?

    [Photoshop CS4, MacOS 10.5.8]
    I'm frustrated in trying to create an action make a channel into a layer. 
    Sounds easy, right?
    I'm got hung up on several issues though, which raised a bigger question:
    • In the approach I'm taking, I want to select the target channel during the action. 
    When I click on Channel X during recording, the action records the step as
    "Select X Channel"
    Unfortunately the particular channel is hardwired into this command so that would
    mean making three different versions of the action.  I have tried looking for a
    more general form of the command, like Select Channel that then takes the
    particular channel as a parameter, e.g. from a drop-down menu.  That at least
    would work in an action. But no such.  (I tried some other ideas like using
    Calculate or Channel Mixer which come close but not close enough.)
    There's a more lame design: selecting the channel before recording the action, then
    creating and deleting extra "internal" channels in the action -- it does work but it
    isn't where I started so I lost a lot of time trying to find something that appears not
    to exist.
    • The lurking question here is how you find
    (a) whether there even exists an actual generic form of a command
      (b) whether the command works in a way that makes it possible to use in an action
    Web searches don't lend themselves to finding information like "what commands
    don't work in actions".  I would really appreciate pointers to any in-depth documents
    on what commands a user can't get at for recording in actions.

    Sorry about the last post, but i knew i had recorded selecting channels by the number instead of the name.
    Well i found one of my older actions which must have been recorded in an old version of photoshop that named the channels with numbers.
    Anyway, see if this action helps you any. (you have to copy the steps to your action)
    https://acrobat.com/#d=DgfhMCZzmUgKlefycUsnJg
    In an RGB color image: channel 1 is the red channel
                             and
    channel 9 is the alpha 6 channel
    Message was edited by: R_Kelly

  • Xpath expression don't work

    i need to select two "sect" by idtry {
                // parse the XML as a W3C Document
                DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document doc = builder.parse(new File("book1.xml"));
                XPath xpath = XPathFactory.newInstance().newXPath();
                String expression = "//chapter/sect[@id='secC'] | //chatpter/sect[@id='secA']"; //select two attributes (this don't works, why?)
                // obtain the element as a node.
                Node node = (Node)xpath.evaluate(expression, doc, XPathConstants.NODE);but using the same Xpath expression on xsl the expressions works
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:template match="/">
            <xsl:copy-of select="//chapter/sect[@id='secB']| //chapter/sect[@id='secC']"/> 
        </xsl:template>
    </xsl:stylesheet>may xml file <chapter id="chapter1">
            <sect id="secA">
                    <para id="a1">texto a1.</para>
                    <para id="a2">texto a2.</para>
                    <para id="a3">texto a3.</para>
            </sect>
            <sect id="secB">
                    <para id="b1">texto b1.</para>
                    <para id="b2">texto b2.</para>
                    <para id="b3">texto b3.</para>
            </sect>
    <sect id="secC">
                    <para id="c1">texto b1.</para>
                    <para id="c2">texto b2.</para>
                    <para id="c3">texto b3.</para>
            </sect>
    </chapter>can anyone help?

    The result of the query consists of two nodes. If you want to access both of them, use the NodeList type in place of the Node type:NodeList nodeList = (NodeList)xpath.evaluate(expression, doc, XPathConstants.NODESET);

  • Cookies Don't Work Properly

    OK, I've looked through this Forum carefully and tried everything.... Even though cookies for certain web sites (NYTimes, WatchGeeks) appear in Safari Preferenes they don't work, Why?
    My settings are as follows: Block Cookies from Third Parties, etc.; Prompt from website one time only. The NYTimes cookie indicates Cache, Cookies & Local Storage. NYT cooke indicates Cookie. But every time I go from one page to another on their site, the sign-in screen re-appears. I'm using Last Pass to sign me in and I'm good until i go to another page. Then the same thing happens. With WatchGeeks, I'm prompted to sign it every time I return to the site...same problem.
    I have deleted all cookies and started over, but that doesn't solve the problerm. Safari recognizes and stores the cookies again, but they don't work properly.This all started when I started to use  'Cookie" a cookie management program. But once this started, I uninstalled "Cookie'" and removed all traces of it, to no avail.
    What's wrong? Can I do something in Time Machine to get me back on track? I'm open to any and all suggestions. Thanks!

    You can check on the <b>about:config</b> page if the javascript.enabled pref is set to true.
    *http://kb.mozillazine.org/about:config
    You can try basic steps like these in case of issues with web pages:
    Reload web page(s) and bypass the cache to refresh possibly outdated or corrupted files.
    *Hold down the Shift key and left-click the Reload button
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Command + Shift + R" (Mac)
    Clear the cache and the cookies from websites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Javascript debugger don't work

    I love the webdevelopment tool in firefox, but my javascript debugger don't work :(
    I only can pause / unpause javascript but all other buttons have no function.
    Must I activate something in about:config or is my computer too old? (The tilt function is not supported by my graphic card)
    Thanks for answers.

    fifo85 wrote:
    > Hi,
    >
    > I have just tried the following code putting the script
    header to execute it
    > on the client side:
    > <script>
    > if(ParentValue == String("Y"))
    > {
    > EnableSubGroup();
    > }
    > else
    > {
    > DisableSubGroup();
    > }
    > </script>
    onload=function(){
    document.forms["SubForm"].elements["SubGroupDD"].disabled =
    !(ParentValue == "Y")
    This will disable SubGroup if "ParentValue" is not "Y"
    Mick
    >
    > I do not get the object expected error anymore
    > but the functions don't work, why is this?
    >
    > ----Function definition ------
    > <script type="text/javascript">
    > function EnableSubGroup()
    > {
    >
    document.forms["SubForm"].elements["SubGroupDD"].disabled='false';
    > }
    > function DisableSubGroup()
    > {
    >
    document.forms["SubForm"].elements["SubGroupDD"].disabled='true';
    > }
    > </script>
    >
    > Thanks
    >
    > Fifi
    >

  • Javascript functions don't work

    Hi,
    I have just tried the following code putting the script
    header to execute it on the client side:
    <script>
    if(ParentValue == String("Y"))
    EnableSubGroup();
    else
    DisableSubGroup();
    </script>
    I do not get the object expected error anymore
    but the functions don't work, why is this?
    ----Function definition ------
    <script type="text/javascript">
    function EnableSubGroup()
    document.forms["SubForm"].elements["SubGroupDD"].disabled='false';
    function DisableSubGroup()
    document.forms["SubForm"].elements["SubGroupDD"].disabled='true';
    </script>
    Thanks
    Fifi

    fifo85 wrote:
    > Hi,
    >
    > I have just tried the following code putting the script
    header to execute it
    > on the client side:
    > <script>
    > if(ParentValue == String("Y"))
    > {
    > EnableSubGroup();
    > }
    > else
    > {
    > DisableSubGroup();
    > }
    > </script>
    onload=function(){
    document.forms["SubForm"].elements["SubGroupDD"].disabled =
    !(ParentValue == "Y")
    This will disable SubGroup if "ParentValue" is not "Y"
    Mick
    >
    > I do not get the object expected error anymore
    > but the functions don't work, why is this?
    >
    > ----Function definition ------
    > <script type="text/javascript">
    > function EnableSubGroup()
    > {
    >
    document.forms["SubForm"].elements["SubGroupDD"].disabled='false';
    > }
    > function DisableSubGroup()
    > {
    >
    document.forms["SubForm"].elements["SubGroupDD"].disabled='true';
    > }
    > </script>
    >
    > Thanks
    >
    > Fifi
    >

  • Don't work Runtime.getRuntime().exec

    Hi. I've written a simple programm, but it don't work(sorry for my english:)):
    import java.io.*;
    class MsgFormat {
         static String hostname;
         static String message;
    public class jPopUp {
         public static void send(MsgFormat msg) {
              if(msg.message.length()!=0) {
                   if(msg.hostname.length()!=0) {
                        try {
                             Process proc = Runtime.getRuntime().exec("echo " + msg.message
                                                                                                                                      + " | smbclient -M " + msg.hostname);
                             } catch (java.io.IOException e) {
         public static void main(String[] args) {
              try
                   MsgFormat mess = new MsgFormat();
                   System.out.println("Enter hostname: ");
                   BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                   mess.hostname = in.readLine();
                   System.out.println("Enter your message: ");
                   mess.message = in.readLine();
                   send(mess);
              catch (java.io.IOException e) {}
    }

    The exec method isn't a shell. Try with something like this:String[] exec = {"/bin/bash",
                     "-c",
                     "echo "+msg.message+" | smbclient -M "+msg.hostname};
    Process proc = Runtime.getRuntime().exec(exec);

  • How to find name of report if I know name of instance and location of instance in Output File Store

    Hello all,
    can somebody help me to find name of the report if I know name of report instance and also location of instance in Output File Store. It should be done via Query Builder.
    It is ...rpt file as output from Crystal Reports. I tried few commands in Query Builder but usually they finished with timeout error.
    Could you help me and send specific command? Or way how to change timeout of Query Builder?
    Thanks.
    matus

    Hello all,
    We finally found solution.
    We knew that file is located on path .../Output/a_145/009/002/133521/~ce10c.....9332.rtf
    This file has more than 2 GB. We tried to find which report is related and provide necessary actions.
    As I mentioned we still failed due to timeout error - There was an error retrieving data from the server: CMS operation timed out after 9 minutes.
    So we tried to use our testing environment. We started there QueryBuilder and there we successfully tested that we found details about files from FileStore /like Name of the report in Launch Pad, CUID, ...
    SELECT SI_NAME, SI_CUID, SI_FILES FROM CI_INFOOBJECTS WHERE SI_FILES.SI_PATH = 'frs://Input/a_148/020/000/5268/'
    or
    SELECT * FROM CI_INFOOBJECTS WHERE SI_FILES.SI_PATH = 'frs://Input/ a_148/020/000/5268/'
    Best regards,
    matus

  • Change "Finder" name in dock.

    Hey guys,
    I'm really into customizing my mac, and I'm trying to figure out how to change the name of the finder icon in the dock, so that when I roll my mouse over the finder icon, instead of saying finder, it will say something of my choice.
    I already did this with my trash icon (making it say "recycling" instead just for the **** of it) so I have tech know how, I just don't know where to look to change the finder name.
    Any thoughts?
    Thanks.

    come to think of it, since finder is an application it probably simply uses the name of the application to show in the dock. that's how it works with all other applications. That would mean that you have to rename Finder.app in /System/Library/CoreServices. However, personally, I would NEVER do something like that. Finder is a part of OS X and its path and its name are likely referenced in lots of places. I have no idea what renaming it would entail. If you feel adventurous go ahead and try to rename it. Make sure you have a good backup and on your head be it.

  • Changing runtime menu item names dynamically in executable

    I want to change the language of my application dynamically. In the run-time menu i do this by changing de item names (leaving de item tags the same) In Labview (6.1) this works but in a application builder build executable this don't work.
    Attachments:
    demo_vi.jpg ‏55 KB
    demo_exe.jpg ‏55 KB

    How are you changing the runtime menu dynamically? Are you reading the menu settings from a file? If so you might be losing the path to the file in the executable.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

Maybe you are looking for

  • Convert from PSE10 to Lightroom - metadata concerns

    After one too many frustrations with PSE, I've been looking for an alternative program.  I don't care about editing - metadata (Organizer type features) are my focus.  I looked at a few non-Adobe programs - a big problem with them is I can't import m

  • I downloaded lion and now safari doesn't work

    After downloading the mountain lion upgrade my safari would not open.  I updated the software, turned off the computer and restarted.  It still won't work.  It's not an internet problem because I can use firefox. Does anybody know how to fix this?

  • "Save Message" - in Task list - Planning 11.1.2.2.302.3

    Hi, We have implemented Planning 11.1.2.2.302.3 and following was asked from our customer. When I enter data (numbers) in the task list, I want to be warn with a pop up window, if I click "next" that "data are not save" --> - save yes or no-. As per

  • Screenshot on an iPad

    How do you take a screenshot on an iPad?

  • Tiff to thumbnail

    I'm scanning thousands of slides (positives) onto my hard drives. I'm using the Nikon coolscan 5000 and batch scanning 50 at a time. I'm saving them to folders labeled by year and saving them as Tiff files. I would like to view them as thumbnails bef