private void executeCommand(final String text) {
        final InputStream procInput;
        new Thread(new Runnable() {

            public void run() {
                try {
                    temp_files_to_clean_up.add(buffer_file.getCanonicalPath());
                    PrintWriter out = new PrintWriter(new FileOutputStream(buffer_file));
                    if (jTextPane1.getSelectedText() != null &&
                            jTextPane1.getSelectedText().length() > 0) {
                        out.write(jTextPane1.getSelectedText());
                    } else {
                    out.write(jTextPane1.getText());
                    }
                    out.close();
                    String env[] = getenv(1);
                    env[0] = "BUF=" + buffer_file.getCanonicalPath();

                    String output = exec(text, env);
                    ThirdIdea.this.shell_output_area.setText(shell_output_area.getText() + output);
                    ThirdIdea.this.shell_output_area.getCaret().setVisible(true);
                    ThirdIdea.this.shell_output_area.setCaretPosition(shell_output_area.getText().length() - 1);
                } catch (IOException ex) {
                    Logger.getLogger(ThirdIdea.class.getName()).log(Level.SEVERE, null, ex);

                } finally {
                    if (jTextPane1.getSelectedText() != null && jTextPane1.getSelectedText().length() > 0) {
                        jTextPane1.replaceSelection(readWholeFile(buffer_file));
                    } else {
                        ThirdIdea.this.jTextPane1.setText(readWholeFile(buffer_file));
                    }
                }

            }

            private String readWholeFile(File file) {
                InputStream in = null;
                String ret = "";
                try {
                    in = new FileInputStream(file);
                    int file_size = Integer.MAX_VALUE;
                    if (file.length() < Integer.MAX_VALUE) {
                        file_size = (int) file.length();
                    }
                    byte[] buf = new byte[file_size];
                    // truncated because for some reason, a byte array is initialized with an int instead of a long
                    // so this's a bit awful, but if you're editing a request bigger than 2G in size, then don't
                    in.read(buf);
                    ret = new String(buf);
                } catch (IOException ex) {
                    Logger.getLogger(ThirdIdea.class.getName()).log(Level.SEVERE, null, ex);
                } finally {
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Logger.getLogger(ThirdIdea.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                return ret;
            }
        }).start();




    }