Need help with runtime exe command

Does anybody know how to get the command with double quotes to work with runtime exe?
String cmd = s+" "+fileName;
fin = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exe(cmd).getInputStream()));
if my s is 'grep -i RTU', the fin would have correct value.
but if my s is 'grep -i "RTU"', the fin doesn't have anything (nothing return from exe(cmd) ).
I tried printing out the cmd, it looks fine ( grep -i "RTU" filename ).
Even when I copy the print of cmd and execute it on unix prompt, it return correct value too.
I also tried excaping double qoutes with backslash. Still doesn't work.
Thank you so much in advance

I tried with the exec(String[]) instead of
exec(String).
Still doesn't work.
I'm using Java 2 SDK, Standard Edition Version
1.3.1_02I am afraid I can't help. I can't duplicate your problem - I have no difficulty passing arguments with or without quotation marks using JDK 1.3. I just wrote a test to be sure, and it worked fine.

Similar Messages

  • Need help with a terminal command

    Ever since Lion, or maybe even earlier, I am fighting a losing battle against memory leaks on my MacBook Pro. Safari for example takes over time 2GB+ for just 2 or 3 tabs open with almost no extensions active. Really strange.
    Someone told me about the "purge" command in Terminal to free some of the sequestered memory, so I am doing this a few times a day to be able to use Photoshop, Keynote, Premiere and other stuff concurrently without opening and closing apps like I did 10 or 15 years ago, remember those days?
    So here are my 2 questions:
    Will this frequent "purge" command harm anything in the long run?
    If no, is it possible to automate this "purge" Terminal action somehow? Maybe a desktop icon to click, or fully automated? I am a designer, not a coder, so I would need help with that.
    Thank you for your input!
      Model Name:          MacBook Pro
      Model Identifier:          MacBookPro8,2
      Processor Name:          Intel Core i7
      Processor Speed:          2.3 GHz
      Number of Processors:          1
      Total Number of Cores:          4
      L2 Cache (per Core):          256 KB
      L3 Cache:          8 MB
      Memory:          8 GB
      Boot ROM Version:          MBP81.0047.B27

    Hello, do any modifier keys work, like Optio/alt?
    Could you have Firmware password protection in Mac OS X ...
    http://support.apple.com/kb/HT1352
    It would block usage of all the startup keys, like C, N, T, D, CMD+s, CMD+Option+p+r, CMD +v, Option, and Shift, as well as booting from anything but the Hard Drive.
    Force Removing Password Protection
    1) Add or remove DIMMs to change the total amount of RAM in the computer.
    2) Then, the PRAM must be reset 3 times. (Command + Option + P + R).
    http://www.securemac.com/openfirmwarepasswordprotection.php

  • Need help with Set-ADUser command

    I need a little help with the following command. Im new to PS and I have found this command but it is only one user at a time. I need to be able to update ALL users in AD.
    My goal is this. Someone before me set all Users Home numbers to 1234567899 and I need to remove that and leave it blank. The command below allows me to do that but only one user at a time by entering their SAMID.
    Is there a way to do this for everyone in AD ?
    Set-AdUser –Identity SAMID –HomePhone $NULL

    Yeah sure - 
    Get-Aduser -filter * -properties SamaccountName | Select SamAccountName | % {Set-Aduser -identity $_.SamaccountName -HomePhone $null}

  • Need help with Runtime.exec()

    I need help getting my program to run a different java program through the command prompt using the runtime.exec() method. This is my code so far:
    import javax.swing.JOptionPane;
    import javax.swing.JDialog;
    import javax.swing.JButton;
    import javax.swing.JRadioButton;
    import javax.swing.ButtonGroup;
    import javax.swing.JLabel;
    import javax.swing.ImageIcon;
    import javax.swing.BoxLayout;
    import javax.swing.Box;
    import javax.swing.BorderFactory;
    import javax.swing.border.Border;
    import javax.swing.JTabbedPane;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.*;
    //import java.Original.*;
    //import java.Turtle.*;
    //import jav.Turtle.galapagos.*;
    public class JavaMenu extends JPanel
         JFrame frame;
         JLabel label;
         JButton select;
         String labDescription = "Java labs created in class.";
         String turtleDescription = "Turtle labs created in class";
         String creationDescription = "Java programs created on my own.";
         public JavaMenu(JFrame frame)
              super(new BorderLayout());
              JPanel lab = labDialog();
              //JPanel turtle = turtleDialog();
              //JPanel creation = creationDialog();
              label = new JLabel("Click Select Program to run the program.", JLabel.CENTER);
              this.frame = frame;
              Border padding = BorderFactory.createEmptyBorder(20,20,5,20);
              lab.setBorder(padding);
              //turtle.setBorder(padding);
              //creation.setBorder(padding);
              JTabbedPane tab = new JTabbedPane();
              tab.addTab("Java Labs", null, lab, labDescription);
              //tab.addTab("Turtle Labs", null, turtle, turtleDescription);
              //tab.addTab("Java Programs", null, creation, creationDescription);
              add(tab, BorderLayout.CENTER);
              add(label, BorderLayout.PAGE_END);
              label.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
         void setLabel(String newText)
              label.setText(newText);
         protected static ImageIcon createImageIcon(String path)
            java.net.URL imgURL = JavaMenu.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
         private JPanel labDialog()
              final int numButtons = 25;
              JRadioButton[] javalabs = new JRadioButton[numButtons];
              final ButtonGroup group = new ButtonGroup();
              select = null;
              final String messageCommand2 = "Lab 02";
              final String messageCommand3 = "Lab 03";
              final String messageCommand4 = "Lab 04";
              final String messageCommand41 = "Lab 04 Extra Credit 1";
              final String messageCommand42 = "Lab 04 Extra Credit 2";
              final String messageCommand5 = "Lab 05";
              final String messageCommand51 = "Lab 05 Extra Credit";
              final String messageCommand6 = "Lab 06";
              final String messageCommand6b = "Lab 06";
              final String messageCommand7 = "Lab 07";
              final String messageCommand71 = "Lab 07 Extra Credit";
              final String messageCommand8 = "Lab 08";
              final String messageCommand8b = "Lab 08";
              final String messageCommand81 = "Lab 08 Extra Credit";
              final String messageCommand9 = "Lab 09";
              final String messageCommand9b = "Lab 09";
              final String messageCommand91 = "Lab 09 Extra Credit 1";
              final String messageCommand92 = "Lab 09 Extra Credit 2";
              final String messageCommand93 = "Lab 09 Extra Credit 3";
              final String messageCommand9a = "Lab 09 American Flag";
              final String messageCommand9t = "Lab 09 Texas Flag";
              final String messageCommand0 = "Lab 10";
              final String messageCommand0b = "Lab 10 Hi Lo Game";
              final String messageCommand01 = "Lab 10 Extra Credit 1";
              final String messageCommand02 = "Lab 10 Extra Credit 2";
              javalabs[0] = new JRadioButton("Lab 02 100 Point Version");
              javalabs[0].setActionCommand(messageCommand2);
              javalabs[1] = new JRadioButton("Lab 03 100 Point Version");
              javalabs[1].setActionCommand(messageCommand3);
              javalabs[2] = new JRadioButton("Lab 04 100 Point Version");
              javalabs[2].setActionCommand(messageCommand4);
              javalabs[3] = new JRadioButton("Lab 04 Extra Credit 1");
              javalabs[3].setActionCommand(messageCommand41);
              javalabs[4] = new JRadioButton("Lab 04 Extra Credit 2");
              javalabs[4].setActionCommand(messageCommand42);
              javalabs[5] = new JRadioButton("Lab 05 100 Point Version");
              javalabs[5].setActionCommand(messageCommand5);
              javalabs[6] = new JRadioButton("Lab 05 Extra Credit");
              javalabs[6].setActionCommand(messageCommand51);
              javalabs[7] = new JRadioButton("Lab 06A 100 Point Version");
              javalabs[7].setActionCommand(messageCommand6);
              javalabs[8] = new JRadioButton("Lab 06B 100 Point Version");
              javalabs[8].setActionCommand(messageCommand6b);
              javalabs[9] = new JRadioButton("Lab 07 100 Point Version");
              javalabs[9].setActionCommand(messageCommand7);
              javalabs[10] = new JRadioButton("Lab 07 Extra Credit");
              javalabs[10].setActionCommand(messageCommand71);
              javalabs[11] = new JRadioButton("Lab 08A 100 Point Version");
              javalabs[11].setActionCommand(messageCommand8);
              javalabs[12] = new JRadioButton("Lab 08B 100 Point Version");
              javalabs[12].setActionCommand(messageCommand8b);
              javalabs[13] = new JRadioButton("Lab 08 Extra Credit");
              javalabs[13].setActionCommand(messageCommand81);
              javalabs[14] = new JRadioButton("Lab 09A 100 Point Version");
              javalabs[14].setActionCommand(messageCommand9);
              javalabs[15] = new JRadioButton("Lab 09B 100 Point Version");
              javalabs[15].setActionCommand(messageCommand9b);
              javalabs[16] = new JRadioButton("Lab 09 Texas Flag");
              javalabs[16].setActionCommand(messageCommand9t);
              javalabs[17] = new JRadioButton("Lab 09 American Flag");
              javalabs[17].setActionCommand(messageCommand9a);
              javalabs[18] = new JRadioButton("Lab 09 Extra Credit 1");
              javalabs[18].setActionCommand(messageCommand91);
              javalabs[19] = new JRadioButton("Lab 09 Extra Credit 2");
              javalabs[19].setActionCommand(messageCommand92);
              javalabs[20] = new JRadioButton("Lab 09 Extra Credit 3");
              javalabs[20].setActionCommand(messageCommand93);
              javalabs[21] = new JRadioButton("Lab 10 A 100 Point Version");
              javalabs[21].setActionCommand(messageCommand0);
              javalabs[22] = new JRadioButton("Lab 10 B 100 Point Version");
              javalabs[22].setActionCommand(messageCommand0b);
              javalabs[23] = new JRadioButton("Lab 10 Extra Credit 1");
              javalabs[23].setActionCommand(messageCommand01);
              javalabs[24] = new JRadioButton("Lab 10 Extra Credit 2");
              javalabs[24].setActionCommand(messageCommand02);     
              for (int k = 0; k < numButtons; k++)
                   group.add(javalabs[k]);
              javalabs[0].setSelected(true);
              select = new JButton("Select Program");
              select.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        String command = group.getSelection().getActionCommand();
                        if (command == messageCommand2)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                 try
                                    Runtime.getRuntime().exec(new String[] {"cmd", "set classpath=D:/Documents and Settings/Yinon Michaeli/My Documents/CS/java/Labs02", "path C:/j2sdk1.4.0/bin", "java Lab020"});
                                    //File file = new File("java/Labs02");
                                    //Runtime.getRuntime().exec(new String[] {"rundll32", "url.dll,FileProtocolHandler","file:///" + file.getAbsolutePath()});
                                 catch (Exception a)
                                      JOptionPane.showMessageDialog(frame, "Error: Exception.", "Error", JOptionPane.ERROR_MESSAGE);
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand3)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand4)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand41)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand42)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand5)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand51)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand6)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand6b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand7)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand71)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand8)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand8b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand81)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand91)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9t)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9a)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand92)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand93)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand0)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand0b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand01)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand02)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        return;
              return create2ColPane(labDescription + ":", javalabs, select);     
         private JPanel createPane(String description, JRadioButton[] radioButtons, JButton showButton)
              int numChoices = radioButtons.length;
            JPanel box = new JPanel();
            JLabel label = new JLabel(description);
            box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
            box.add(label);
            for (int k = 0; k < numChoices; k++)
                box.add(radioButtons[k]);
            JPanel pane = new JPanel(new BorderLayout());
            pane.add(box, BorderLayout.PAGE_START);
            pane.add(showButton, BorderLayout.PAGE_END);
            return pane;
        private JPanel create2ColPane(String description, JRadioButton[] radioButtons, JButton showButton)
            JLabel label = new JLabel(description);
            int numPerColumn = radioButtons.length/2;
            JPanel grid = new JPanel(new GridLayout(0, 2));
            for (int k = 0; k < numPerColumn; k++)
                grid.add(radioButtons[k]);
                grid.add(radioButtons[k + numPerColumn]);
            JPanel box = new JPanel();
            box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
            box.add(label);
            grid.setAlignmentX(0.0f);
            box.add(grid);
            JPanel pane = new JPanel(new BorderLayout());
            pane.add(box, BorderLayout.PAGE_START);
            pane.add(showButton, BorderLayout.PAGE_END);
            return pane;
        private static void createAndShowGUI()
             JFrame.setDefaultLookAndFeelDecorated(true);
             JFrame frame = new JFrame("Java Programs");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JavaMenu newContentPane = new JavaMenu(frame);
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    Why are you posting hundreds of lines of code not related to the problem??? 99.9% of the code you posted has absolutely nothing to do with using the Runtime.exec() method.
    Create a simple test program that simply tries to invoke the Runtime.exec() method. Once you get that working, then you incoporate it into you real program. Don't clutter the forum with unnecessary code.
    public class WindowsFileProtocolHandler
         public static void main(String[] args)
              throws Exception
              String[] cmd = new String[4];
              cmd[0] = "cmd.exe";
              cmd[1] = "/C";
              cmd[2] = "java";
              cmd[3] = "YourClassHere";
              Process process = Runtime.getRuntime().exec( cmd );
    }

  • Need help with Runtime.getRuntime().exec

    If there is a better place to post please let me know. I need some help understanding what is going on and was hoping someone might be able to provide some information. I would like to use Runtime.getRuntime().exec to copy a file in linux. Here is the code I am using:
    try {
    Process p = Runtime.getRuntime().exec("cp -v foo foo2");
    BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = null;
    while ((line = in.readLine()) != null) {
    System.out.println(line);
    } catch (IOException e) {
    e.printStackTrace();
    If I use cp, with the System.out.println(line) I can see that it has copied and of course when I check the command line indeed it has. My problem is that I really need to use the dd command, but I can't see the output that dd displays. It copies the file just fine but I need the output. If someone can provide some explaination or help I would really appreciate it. Thanks.

    By default, dd sends its output to stdout, so any status messages it has go to stderr. Use getErrorStream (double check the docs for the method name) just like you're currently using getInputSTream.

  • Need help with Runtime class in UNIX

    I am attempting to kick off a C++ executable from within java. This class is called through a UI.
    The executable runs in the form of the exec followed by name=value pairs, ie [path/exec] [n=v] [n=v] ... and runs fine from the command line.
    Examples: These don't kick it off, but don't error either.
    String cmd[] = {"/bin/sh","-c","[path]/[exec] [n=v]};
    String cmd[] = new String[3];
    cmd[0] = "[path]/[exec]";
    cmd[1] = "[n=v]";
    cmd[2] = "[n=v]";
    Process p = Runtime.getRuntime().exec(cmd);
    I'm thinking it may be an environment issue, ie env vars not set because the only way I can get this to work is to put the command in a shell script that sets the env vars and kicks off the executable. Like:
    String cmd[] = {"/bin/sh","-c","/[path]/test.sh"};
    I'd prefer to kick this off from the java code. It sounds like I need to find a way to shell out, run our script to set env vars, then kick off the exec. This is my first attempt w/ using Runtime, so maybe I'm missing something.
    Thanks in advance for the help.

    I think this sort of thing will depend upon the shell you're in. When you use Runtime.exec you (might) lose your "parent" shell's environment variables - this question shows up here now and again, here's one thread that might help:
    http://forum.java.sun.com/thread.jspa?threadID=468648&messageID=2172572
    You might find some enlightenment on Roedy's Java Glossary here: http://mindprod.com/jgloss/exec.html
    Hope that helped
    Lee

  • Not a developer but need help with runtime error, please

    Hi, I have downloaded a game called Fishdom, but it will not open. I get a " The application has requested the Runtime to terminate it in an unusual way" error message. The dialog box is labeled "Microsoft Visual C++ Runtime Library". 
    I checked my programs and I have C++ '05, '08, and 2010. I am using XP SP3.  I don't get this error at any other time.
    I have asked Playrix (game distributor) about it and they seem relatively clueless about how to fix it. So, is there anything I can do to fix this error, or bypass the error so that the game will load? I've tried deleting and reinstalling the libraries and
    that did not help.
    Anything you can suggest will be very helpful, because I do want the game and do not want to argue with them about refunding my money for it.

    Hi CatsinQ,
    Thank you posting in MSDN forum.
    According to your description, could you please tell us when you installed the
    Microsoft Visual C++ Runtime Library if there have any install errors?
    If you can install the Microsoft Visual C++ Runtime Library successfully, I think that the issue is more related to the game. Therefore, I suggest you can ask the issue to Playrix
    (game distributor), maybe it will better help you.
    In addition, since the
    Visual Studio General
    Forum which discuss Visual Studio the VS IDE issue, so I suggest you can try Brian’s suggestion.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • NEED HELP WITH RUNTIME ERROR!

    I have recently formated my laptop and installed Adobe Reader. Every time I try to open a .pdf I get the message below:
    Runtime Error!
    Program: c:\program files\adobe\reader 9.0\readeacroRd32.exe
    This application has requested the Runtime to terminate it in an unusual way. Please contact the applications support team for more information.
    I always click to report it to windows but there is no link to fix this issue. What can I do?
    Thanks.

    That hotfix applies to XPSP2. Is that what you've installed? If so,
    you should probably upgrade to SP3, which includes a later version
    of that and many other msvc files. If you're not using XP, then
    that's not the solution.
    Noel

  • Need help with calc all command..

    Hi All,
    I have a situation where I need some of the members in accounts dim not be aggregated but some to be aggregated..
    so i used.............. calc all except mbr(mbmr_name)
    but still i see that the values for this member roll up
    can any one help me this
    thanks in advance

    With knowing all the details, I would suggest maybe creating an alternate hierarchy to provide you another look at aggregate data minus the accounts you are not wanting to aggregate. Just a thought, there are several ways to work this issue......but this is the first I would suggest looking into. If it gets more complicated, then I would explore creating calc script logic utilizing UDA's. Hope this helps.
    JC

  • Need help with Runtime error! Can't find "MediaDatabase" file! Folders are visible!

    Hi, I have been searching a lot for an answer to this issue. Elements keeps crashing after about five minuets and giving me "Microsoft Visual C++ Runtime Library" "Runtime Error!" "R6025 - pure virtual function call". I am running Premiere Elements 9.0 on windows 8.1 and I am trying to
    rebuild the "mediadatabase.db3" file, but cannot find it. I made my hidden folders visible, and followed the pathway, but I only get this. I have searched and searched but I can't find anything about windows 8.1. Only 7 and vista. Thanks in advance!

    Look for a line that resembles the following in the
    actionscript of the Flash fla files... It is likely to be in the
    first frame's code, but may not be.
    xmlData.load("teamTSI_en.xml");
    the '
    xmlData' part of that is not likely to be the same as what's
    in your file, it's a variable so it could be anything, and the file
    names will be whatever your xml files are.
    If you can post that line of code from each of the fla files,
    someone may be able to tell you where you need to place the xml
    files.

  • I need help with the following commands

    I had to reformat my Imac. At first I didn´t knew how to do it... so I google for some info and I found this:
    start iMac while holding down the CMD+S for the computer to boot into single user mode.
    Then:
    Type: /sbin/mount -uw / ENTER
    Type: rm /var/db/.applesetupdone ENTER
    Type: rm -R /Users/* ENTER
    Type: shutdown -h now ENTER
    the iMac is turned off and is like new.
    After I did this nothing happend.... So I called the Technical Service and they explained me very well how to reformat my iMac.
    start iMac while holding down alt
    Then:
    Recovery HD > Disk Utility
    Then:
    Select Macintosh HD and Erase ...
    After doing this... I reinstalled Lion from the internet.
    My questions are:
    Does the introduction of the commands (/sbin/mount -uw / ENTER, rm /var/db/.applesetupdone ENTER, etc...) may have caused a problem??
    If so.. reformat the imac as the Technical Service explained me would have solved??
    Thanks a lot

    Yes all solved :-(

  • New to automator, need help with a pause command

    OK, here's what I am trying to do. Open an shn (compressed audio) file with Shorten to decompress to WAV, then open the WAV with iTunes and convert to AAC.
    I am unable to set a default folder for output from Shorten, so my current plan is to select all the files, doubleclick and set a desktop folder for the WAV output. I made a folder action for that destination to automatically convert to AAC with iTunes and delete the source files. That folder works fine if I drop all WAV files in, but when they get sent one at a time from Shorten, then only a few of the files get routed to iTunes and the rest stay in the folder unconverted.
    I have tried to use "ask for confirmation" which did not work, neither did "wait for user action". I can't use "pause" because each job will be different so I cannot predict how long it will take.
    This is my first attempt at Automator and I think I've done pretty well so far (setting the folder action took quite a while to figure out). Any advice would be appreciated.

    Just a quick response, but...
    I would try making a workflow that just takes the desktop, gets it's contents, filters them for WAV files, then does your iTunes-thing. It's not as easy as just having a folder action, but it should work correctly. Folder actions tend not to work as well when you aren't actually dropping items onto them. They're kind of glitchy in my opinion.

  • Can anyone help with Adobe_Updater.exe command line options?

    Hi,
    I am trying to run the updater silently to update Reader.
    Thanks,
    SteveJ

    Try these...
    msiexec /p <patch.msp> /qn --- silent install
    msiexec /p <patch.msp> /qb – progress bar install

  • Need help with complex column creation command

    Hello, all
    I need help with a complex column creation command and SQL anywhere help is not sufficient for it.
    Here is the situation:
    I need to write a generic DDL "alter table" command, which can add/modify columns without knowing in advance if they already exist in the destination table.
    Is there a command, which looks like:
    alter table "table1" add (on existing modify) column1 <datatype> <default> ?
    Thank you,
    Arcady

    Hi.
    I don't think this is supported in alter table command. But you can code that inside an if statement which queries systables & syscolumns. Your code should be something like that:
    if (select count(*) from sysobjects, syscolumns where sysobjects.id = syscolumns.id and sysobjects.name = 'some_table' and syscolumns.name = 'some_column') < 1
    begin
        alter table some_table add some_column numeric(12) not null
    end
    This is an example..
    Andreas.

  • FTP Adapter with Runtime OS Command before Message Processing

    Hi PI Techies,
    I have a confusion in using Sender FTP Adapter with Runtime OS Command before Message Processing.
    Scenario is like this:
    Ftp Adapter has to pick a file from FTP server after it checks that a Blank Marker file exists on PI server AL11 directory say "tmp directory".
    For this I am using Runtime OS Command before Message Processing where a shell script will check the existence of Blank Marker file on PI server AL11 and if found , it exits the script and FTP Adpater will then pick the Actual Data File and Process it.
    Now Confusion:
    I am confused in technical execution of steps by FTP Adapter..
    Whether FTP Adapter polling initiates the Interface or Runtime OS command checking the File existence will initiate the Interface?
    May be its follish to you guys... but please answer ..
    Regards,
    Anurag

    Hi,
    I will take it other way as we need to process the Data File not Marker File ( its just for checking the Data File is completely written on FTP server).
    Other way mean " Will Poll for Data.txt File and if  found then Runtime OS Command will do connect to FTP and check if Marker File exists, if yes then delete the marker file and read the actual Data File for processing.
    Please let me know, if Marker File does not exists on FTP folder, will it still read the Data File or will it exit the Adapter execution?
    Your help is much appreciated.
    Regards,
    Anurag

Maybe you are looking for