How to deal with pipe in the Java system call?

Hi, all,
I tried to use a system call in java. The command contains a "|" pipe. It works both in perl and C if I do {color:#3366ff}system("ls -l | wc"){color}, but when I do it in Java, I didn't get anything returned. Here is the code
{color:#3366ff}import java.io.*;
class SystemCall{
public static void main(String[] args) throws IOException {
StringBuffer sb = new StringBuffer();
Process p = Runtime.getRuntime().exec("ls -l | wc");
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null) {
System.out.println(line);
}{color}
If I use Runtime.getRuntime().exec("ls -l"), the code returns correctly. Does anyone know the solution?
Thanks

When you exec a process, it doesn't go through the shell. The I/O redirection symbols are interpreted and used by the shell.
You have a few options.
One is to not use Runtime.exec at all. You really don't need it for what you're doing -- the stuff in java.io is fine for that.
Another is to exec multiple processes and do the redirection in Java yourself. I wouldn't recommend that, but it's an option.
Another is to exec a shell, and pass your program to it as a shell script or as a one-line script passed on the command line.
I'd suggest the first one in this case.
By the way, what you're doing isn't really a "system call". You're forking and exec'ing a process (or really, multiple processes).

Similar Messages

  • How to deal with '$' sign in the class name?

    I want to put my Java Applet game on my homepage. But the server which I set up my homepage doesn't support the file name like XXX$XXX.class, which has '$' sign in the file name. Would anyone can tell me how to deal with this problem? And how can I make the game work on my homepage? Thanks.

    Don't forget, this include both concrete inner classes as well as any anonymous inner classes you create, like
    myButton.addActionListener(new ActionListener()
      // Yada Yada Yada

  • How to deal with customer motive in three system landscape?

    Hello,
    I am developing a portal application based on the Composition Environment 7.1 in a three system landscape. Now, I have created a customer motive on the development system.
    What is the proposed way to transport this motive from the development system to the quality aussurance and the production system?
    Is there some sort of transport mechanism or do I have to export / import the motive?
    Best regards
    Alexander

    Hello,
    Portal themes can be moved use the theme transport tool. From system admin -> portal display -> theme transport there is an option to store a theme as a zip file and then you can upload it to another portal.
    I know that this is possible. My question is, whether this is the preferred (or intended) way to do this.
    Best regards
    Alexander

  • How to deal with dust on the rear camera

    So for some time now I have noticed some fuzzy dark areas on my rear facing camera, to the point where I can see dust on the lens but I can not seem to make it move. I have tried using compressed air to get it off but I think it is behind the lens?!? I don't know how that is even possible. However I don't know where to turn to get this fixed. I do not have apple care because a rep fed me the line that I was unavailable because I was over 20 min of talk time when I wanted to get it less than 2 weeks after getting the phone. Does anyone know what I could do? Thanks.
    -Alex
    iPhone 5
    iOS 7.1.2

    there is a huge long thread of messages about the camera dust issue:
    Is there dust inside camera lens of iPhone 5?
    personally myself would tell you if the iphone is out of warranty (you said you don't have applecare) and if the apple store won't fix it for you, then go to a repair shop that fixes iphones. look them up on yelp and read the reviews on the shops to find one you are comfortable with. yelp has been the best site that helped me in finding the best iphone repair shop in my area - look for lots of favorable reviews at the shops you may see listed near you to give you a clue as to which shops to narrow down your selection. another alternative is to do it yourself by opening up the iphone, simply lifting the camera sensor without disconnecting it, and directly blowing out the lens (which is actually part of the case) with that compressed air. can personally say this is relatively easy to do, but if you don't have the courage or incentive to do it, then don't do it yourself. if it turns out that the dust is actually in the camera sensor, then that part has to be replaced. get a repair shop to do that because that involves taking more of the iphone apart. the repair shop that has worked on three of my iphones would do a camera fix for $35. you'll have to call around in your search to find a shop and ask for quotes to do this stuff for you. the other alternative is you'll have the apple store probably suggesting that you buy a replacement iphone 5 if they still have them.

  • How to deal with "criminals" in the appstore?

    I have discovered a developer, Brian Hall, the creator of games such as Elven Knight, Pegasus Flight, Temple Run and many more games, that i beIieve can be marked as a criminal. His games are totally worthless, they are all exactly the same except for the graphics, and the screenshots and the descriptive text are absolutely misleading. It is obvious that this Brian Hall is trying to cheat appstore users in buying one or more (depending your taste for e.g fantasy, zombies, cute ponies etc) of his apps. Game play is absolutely worthless and in no way even remotely matches with what the description leads you to believe. Brian Hall obviously just wants to make quick money by cheating the appstore public with his worthless apps.
    I have bought one of his games and posted a review stating much the same as above, but i even suspect that negative reviews are somehow removed again, since I can no longer see it.
    In my opinion, people like Brian Hall and his apps should at least be BANNED from publishing in the appstore, if not actually persecuted for his close to criminal behaviour. Please advise to who or where i can address this issue properly, if anyone reading this knows how to....
    Thanks,
    T Kuster

    I don't know if this will help, but if the app was from the Mac App Store you could try the 'Contact Support' link:
    http://www.apple.com/uk/support/mac/app-store/contact/
    If it's from the iTunes App Store:
    http://www.apple.com/uk/support/itunes/
    (These are the UK links, which may not be the stores you need - I think you can just change the 'uk' in the link to the recognised international abbreviation for the store you want to contact).

  • How to deal with BRS for the below scenario?

    Hi,
    I would like to know the solution for the below scenario for BRS:
    I have a customer who was maintaining their accounts with Tally software for their previous Financial Year. This year they have shifted to SAP B1 2005B. They have issued few cheques for their vendors in the month of march 2008 which has been realised in the month of April 2008. As per Tally, the closing balance of their bank is 8 Lakh but as per the bank statement, their closing balance is 23 Lakhs. In SAP, the opening Balance for the bank is considered as 23 Lakhs. Now there are 15 Lakh worth cheques which were not realised for the month of March 2008.
    Example:
    abc a/c - 3Lakh
    def a/c - 5lakh
    xyz a/c - 7 lakh
    How do i reconcile for this scenario and what procedures do i follow in SAP?
    Thanks and Regards,
    Kaushal

    Hi Kamlesh,
    Thanks for your response.
    Actually, In the "Process External Bank Statement" window, i see that there are few entries which is for the previous year and which has not been reconciled. I have never worked practically on BRS and hence, i am scared to make any changes in the clients database without being confident on what i am doing. I need to reconcile for one of their Bank a/c for the month of April '08. I have the copy of the statements for the month ending 31st Mar 08 and 30th Apr 08. The closing balances are as below:
    31/03/08 - 2300000.00
    30/04/08 - 3100000.00
    Now my OB for Bank a/c for April '08 in SAP is 2300000.00 Dr.
    When i go to External Bank Reconciliation - Selection Criteria Screen (Manual Reconciliation), here are the detail that i enter:
    Last Balance: INR -7,000,000.00000 (Grayed out by the system)
    Ending Balance: INR -3,100,000.00000 (Entered by me)
    End Date: 30/04/08 (Entered by me)
    "Reconciliation Bank Statement" Screen opens up and shows the below balances in the screen:
    Cleared Book Balance: INR -7,000,000.00000
    Statement Ending Balance: INR -3,100,000.00000
    Difference: INR 3,800,000.00000
    As per the Bank statement, i have found all the transactions listed out here for the month of Apr '08 but, i also found that the open transactions for the previous month from April '08 have been lying in "Process External Bank Statement" window.
    Could you please help me solve my issue as to what needs to be done or could you also get me some links from where i can get few documents for processing External Bank Reconciliations?
    That will be of a great help for me. I need steps as to what needs to be done first and then the next so that i can arrive at the correct closing balance for the month April '08.
    Thanks in Advance....
    Regards,
    Kaushal

  • How to deal with int64 in the OCCI country

    Gyus, I'm trying to convert int64 to Number in order to to use it within OCCI (Windows, VS2005).
    But the hard point is that I'm using InstantClient 10.2 while Oracle client 9.2 is installed on my machine as well. In order to be able to set everything up I had to unset the NLS registry key. Because if I have the HKLM\SOFTWARE\ORACLE\NLS_LANG key untouched I get an exception at env->createConnection.
    But my current guess is that without this key I couldn't use Number.fromText(), right?
    Actually, what I'm trying to do is (C++/CLI code):
    Number num;          
    num.fromText(env, "277301159723", "999999999999");
    vectorArray.push_back(num);
    setVector(stmt, index, vectorArray, schemaName, typeName);
    the bold part throws this exception:
    OCI-21500: internal error code, arguments: [kadcbeg02], [], [], [], [], [], [], []
    Could anybody tell me why should I give twelve 9th as nls??
    Why "numberIsNull" is true after my "fromText" call??
    Does this code works on your machines? If yes I would blame the registry key.. But then I do not see if it is possible to use complicated logic with OCCI InstantClient and VS2005 having Oracle Client installed on the same machine (for sure, if oracle client is not 10.x)

    OK, it seems that the problem has nothing to do with NLS registry key, and the correct way to run this fromText stuff is to initialize Number beforehand:
    Number num =0; //yeah, just =0 helps
    num.fromText(env, "277301159723", "999999999999");
    std::string text = num.toText(env, "999999999999");
    works pretty well.
    But let me put some nitpicking here: while initializing doesn't seem to be a very sophisticated operation, I haven't found any oracle doc that states this explicitly. Moreover, all the docs state that I don't need (!!!!) to initialize the Number before I use it. How could this be possible??! Even this excellent oracle ppt lies: http://www.oracle.com/technology/tech/oci/occi/downloads/OCCI.ppt.
    Though, maybe the problem is only with C++/CLI at VS2005? Could anybody could run the code above without explicit "=0" and without getting an exception?
    And again, I'm still encountering the same error while calling setVector :
    OCI-21500: internal error code, arguments: [kadcbeg02], [], [], [], [], [], [], []
    Any suggestions are appreciated.

  • Loading external swf, how to deal with errors within the loaded swf?

    I have a Flex app that basically lets you browse a bunch of thumbnails that represent swf files, when you click a thumbnail it opens a window that loads the actual swf into an image control. The problem I have is that these swfs can be uploaded by our clients, so they may have actionscript errors being thrown, etc. We can't really predict what they may do. Is there a way I can load these swf in such a way as to ignore any errors that the loaded swf may generate within itself.
    For example, one such swf reads some text from a text file to display, but when they are viewing it in this manner the file isn't there so a stream error is generated. My parent Flex app doesn't care about this error and I don't want to see it thrown up in an actionscript error box (I have debug verison loaded on my PC obviously) or interfere with the parent app in any way.
    Would application domains help at all? Would it make a difference if I loaded the swf into a separate domain? Or is there some way I can generically trap any error coming from the loaded swf and just ignore them?
    Any help appreciated.
    Thanks,
    Marcus

    There is no way to catch errors thrown at random times.  Remember that most folks have the release player which does not show error dialogs.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • How to deal with franch character in java inside string

    while storing in the data base the values are going to changed

    You need to reformat the partition the DB is stored on to be in Unicode.

  • How to deal with the product price difference g/l account

    Hi:
    When I went to the transaction fs10n to look at the g/l account 281500(gain from own product price differences) and I found there has 40 EUR in credit column,then the cumulative balance is credit 40 EUR,obviously this 40 EUR credit is due to the difference between order price and invoice price. My question is how to deal with it?

    The Finance department needs to coordinate it with the Purchasing on the correct price. If the invoice price is the correct one, then there is a need to recognize the difference as per accounting standard. If in case that the order price is the correct one, they should inform the Vendor about it and once the Debit or Credit note is received, you just need to post it as "subsequent debit or credit" the amount will offset to this price difference.

  • Help!!! How to deal with ClassNotFoundException??

    How to deal with ClassNotFoundException without starting Java Runtime Environment??
    the class file:
    import java.applet.Applet;
    import java.awt.Graphics;
    public class Hello extends Applet {
    public Hello() { }
    public void paint(Graphics g) {
    g.drawString("Hello!", 5, 25);
    the html file:
    <APPLET CODE="Hello" WIDTH=300 HEIGHT=200 >
    </APPLET>
    But it throw a error
    Error loading class: Hello
    java.lang.NoClassDefFoundError
    java.lang.ClassNotFoundException: Hello
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
    at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
    at com/ms/applet/AppletPanel.run (AppletPanel.java)
    at java/lang/Thread.run (Thread.java)
    What 's the rule of com.ms.vm.loader.URLClassLoader finding the class??

    If you compiled the applet with SUN jdk then use -source 1.3 -target 1.1 to make it run in
    msjvm (Microsoft Java Virtual Machine). Note that this is a bad idea because MS is
    phasing out the msjvm.
    If you don't want to ue msjvm (good for you) than use the object tag in your html file to tell
    the browser you need to run this applet with sun jre:
    http://java.sun.com/products/plugin/versions.html

  • Move of mailbox with over 30K of folders fails, how to deal with this.

    Hello all,
    I'm in the process of moving all Exchange 2010 mailboxes to newly created databases located on new storage.
    Every mailbox except one moved successfully, the "problem" mailbox keeps failing and I need some advise on how to deal with this.
    The mailbox that keeps failing is only 4 GB but has over 30K of folders that the users created manually over the years.
    They are unable to easelly delete folders as they have created many sub folders within the folders.
    I posted a part of the failed move request log below.
    Can anyone advise on how to solve this?
    Thanks in advance.
    21-2-2015 18:15:13 [EXHUB1] Fatal error MapiExceptionMaxSubmissionExceeded has occurred.
    Error details: MapiExceptionMaxSubmissionExceeded: Unable to save changes. (hr=0x80004005, ec=1242)
    Diagnostic context:
        Lid: 55847   EMSMDBPOOL.EcPoolSessionDoRpc called [length=7574]
        Lid: 43559   EMSMDBPOOL.EcPoolSessionDoRpc returned [ec=0x0][length=360][latency=0]
        Lid: 23226   --- ROP Parse Start ---
        Lid: 27962   ROP: ropWriteStream [45]
        Lid: 27962   ROP: ropSetProps [10]
        Lid: 27962   ROP: ropSaveChangesMessage [12]
        Lid: 17082   ROP Error: 0x4DA     
        Lid: 18273  
        Lid: 21921   StoreEc: 0x4DA     
        Lid: 27962   ROP: ropExtendedError [250]
        Lid: 1494    ---- Remote Context Beg ----
        Lid: 26426   ROP: ropSaveChangesMessage [12]
        Lid: 27420   dwParam: 0xE1F000B
        Lid: 36537   dwParam: 0xE1F000B
        Lid: 5587    StoreEc: 0x8004010F PropTag: 0xE1F000B 
        Lid: 33375   StoreEc: 0x8004010F
        Lid: 27420   dwParam: 0x806684B0
        Lid: 36537   dwParam: 0x806684B0
        Lid: 5587    StoreEc: 0x8004010F PropTag: 0x806684B0
        Lid: 64931   StoreEc: 0x8004010F
        Lid: 46509  
        Lid: 40193   StoreEc: 0x8004010F
        Lid: 5587    StoreEc: 0x8004010F PropTag: 0x30130102
        Lid: 21970   StoreEc: 0x8004010F PropTag: 0x668F0040
        Lid: 64319   dwParam: 0x5000
        Lid: 39743   dwParam: 0x6730
        Lid: 45016   StoreEc: 0x4DA     
        Lid: 57304  
        Lid: 5041    StoreEc: 0x4DA     
        Lid: 4465    StoreEc: 0x4DA     
        Lid: 6926    StoreEc: 0x4DA     
        Lid: 1750    ---- Remote Context End ----
        Lid: 31418   --- ROP Parse Done ---
        Lid: 21457  
        Lid: 19665   StoreEc: 0x4DA     
       at Microsoft.Mapi.MapiExceptionHelper.ThrowIfError(String message, Int32 hresult, SafeExInterfaceHandle iUnknown, Exception innerException)
       at Microsoft.Mapi.MapiProp.SaveChanges(SaveChangesFlags flags)
       at Microsoft.Exchange.MailboxReplicationService.MoveObjectInfo`1.CreateMessage(T obj, GetAdditionalProperties getAdditionalPropertiesCallback)
       at Microsoft.Exchange.MailboxReplicationService.MoveObjectInfo`1.CreateMessage(T obj)
       at Microsoft.Exchange.MailboxReplicationService.LocalMailbox.Microsoft.Exchange.MailboxReplicationService.IMailbox.SaveSyncState(Byte[] key, String syncStateStr)
       at Microsoft.Exchange.MailboxReplicationService.MailboxWrapper.<>c__DisplayClass57.<Microsoft.Exchange.MailboxReplicationService.IMailbox.SaveSyncState>b__56()
       at Microsoft.Exchange.MailboxReplicationService.ExecutionContext.Execute(GenericCallDelegate operation)
       at Microsoft.Exchange.MailboxReplicationService.MailboxWrapper.Microsoft.Exchange.MailboxReplicationService.IMailbox.SaveSyncState(Byte[] key, String syncState)
       at Microsoft.Exchange.MailboxReplicationService.MailboxCopierBase.SaveSyncState(SaveStateFlags flags)
       at Microsoft.Exchange.MailboxReplicationService.BaseJob.SaveSyncState(SaveStateFlags flags)
       at Microsoft.Exchange.MailboxReplicationService.BaseJob.SaveState(SaveStateFlags flags, UpdateRequestDelegate updateRequestDel)
       at Microsoft.Exchange.MailboxReplicationService.MoveBaseJob.SortMessages(Object[] wiParams)
       at Microsoft.Exchange.MailboxReplicationService.CommonUtils.CatchKnownExceptions(GenericCallDelegate del, FailureDelegate failureDelegate)
    Error context: --------
    Operation: IMailbox.SaveSyncState
    OperationSide: Target
    Primary (a4966c13-778a-4d70-9087-f077e2523f66)
    Key: FEF1D04E070AB74A99B809B7797674AE000000000000000000000000000000009B5540B45B37774CAB84806C1964B598
    SyncStateLength: 27050362
    21-2-2015 18:15:13 [EXHUB1] Relinquishing job.

    Hi,
    Based on the description, please run the following commands to check if there are any message limit size. Try to increase the limit size then move this mailbox.
    Get-mailbox –identity “user name” | fl MaxSendSize,MaxReceiveSize
    Get-transportconfig | fl MaxSendSize,MaxReceiveSize
    Get-transportrule | fl MessageSizeOver
    Get-sendconnector | fl MaxMessageSize
    Get-receiveconnector | fl MaxMessageSize
    Note: Once we increased the value we need to wait for the AD replication and cache to be cleared and then test the move mailbox.
    If this doesn’t work, please try to move mailbox with the skip corrupted items. This will skip the corrupted items and move only the good items to the target mailbox.
    Similar thread:
    https://social.technet.microsoft.com/Forums/en-US/5383a826-4383-4b26-a503-2c3bb635f9d2/mailbox-move-to-exchange-2010-fails-for-mailboxes-over-23-gb?forum=exchangesvrdeploylegacy
    Best Regards.

  • How to deal with images when detecting/resizing screen?

    Hi there,
    I am trying to learn how to detect screen resolution and
    resize a flash movie to those dimensions. The one thing I'm
    wondering first is, how to deal with images in the movie.
    Do I need a variety of different movie sizes that I serve up
    depending on the resolution, or is there some way of linking to
    higher rez image that can be scaled down to fit the screen?
    Thanks!

    as far as I know this has always been a bit of an issue when
    using
    images inside a scaled movie. If you display a high res image
    inside a
    scaled down movie, flash can't "reoptimize" it so the image
    looks
    jagged. Of course the other way around is even worse..
    Serving images based on the screen res could be possible if
    you detect
    it using javascript but could be a night mare to maintain and
    test it...
    I guess the questions I would ask myselkf are:
    1. what is my audience? What resolution the majority of them
    will have?
    2. Is there anyway I can keep the image size fixed, and scale
    to fit he
    rest of the design?
    3. How much time do I have to implement the customized
    version?
    It really depends on your project..but to answer to your
    quuestion yes
    you can detect.
    http://www.pageresource.com/jscript/jscreen.htm
    and your flash will have to interpret and load images from
    different
    directories based on the var passed

  • How to deal with credentials for external applications using a Java Client/

    Hi Guys,
    This is the case. I am integrating an external application with an ADF Application. I have implemented some programmatic ViewObjects that are being filled up by a REST Java Client Wrapper. Everything is working fine but the issue is that the credentials the wrapper is using are hard coded inside the java class. I am thinking to ask for the credentials at the beginning of my taskflow and then store them somewhere and use them then to create my client wrapper (passing them in the constructor).
    However, I don't know if my approach is good and I would like you to share your experiences or how to deal with this.
    Regards

    You can use Credential Store Framework to store the credentials securely in the weblogic server instead of hardcoding in the java class.
    The Credential Store Framework:
    - enables you to manage credentials securely
    - provides an API for storage, retrieval, and maintenance of credentials in different back-end repositories
    Check the documentation on CSF API -
    http://docs.oracle.com/cd/E29505_01/core.1111/e10043/devcsf.htm
    Major Steps -
    1. Create a credential map and key in em console to store the password (http://docs.oracle.com/cd/E25054_01/core.1111/e10043/csfadmin.htm)
    2. Use CSF API to retrieve the stored password
    3. In jazn-data.xml give permissions to access CSF key and map

  • How to deal with the barcode?

    i'm developing a file storage system in java, there're two barcode on each file(one is pdf417, the other one is code128) , but now ,there's a problem confused me :
    i use the barcode scanner to scan the file and get images of these files from the scanner , but i have no idea how to deal with these images,
    i need the barcode information on the images, and i know there're some java components can help me to read the barcode from images , for example : BarcodeReader from Barcode Library, but these components were too expensive for me , is there any other way can solve this problem?

    yes, look for a cheaper component...
    Or write your own...
    Or save up until you can afford the more expensive ones...

Maybe you are looking for

  • How to resrict number of line items in IDOC  Payment file

    Hai I had an issue where user wants to restrict the number of line items in the payment IDOC file. Is there any possibilty to restict these number of line items to 6. Because the user has some reporting problem with the bank regarding the IDOC file K

  • OWB won't take mapping changes on first attempt

    Hello, Here is my problem: mapping that was previously validated, deployed and executed successfully requires a minor change. As an example, let's say, I want to change the default value of the column in "Key Lookup" object: from default null to 0. I

  • Can't connect sony xr105e handycam

    Hi all, I've just purchased an imac 21.5" i3 with the hope of using it for basic camcorder footage but it does not seem to register when i connect the camera via a usb port. I've read that the camcorder may not be compatible due to the AVCHD encoding

  • HT3275 Time machine keeps ejecting backup drive

    I haven't been able to make a time machine backup in 63 days.  Getting very concerned.  Running OSX 10.8.2.  Time machine spends a lot of time preparing, and after it finally starts making a backup it fails part way through.  I used to be able to mak

  • How to monitor weblogic Queue

    Hi, we are using weblogic Queue for storing messages . Recently we are facing an issue , when the incoming messages are more then our Queue went down So the question what i am asking is that , if the Queue goes down , can we get any sort of indicatio