gt:         sp.run(new String[] {"sudo", "find", "/"}, false);
context: /**
   * Created : Apr 17, 2012
   *
   * @author pquiring
   */
  
  import java.io.*;
  import java.util.*;
  
  import javaforce.*;
  
  public class BackupPanel extends javax.swing.JPanel {
  
    /**
     * Creates new form BackupPanel
     */
    public BackupPanel() {
      initComponents();
    }
  
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
      private void initComponents() {
  
          jToolBar1 = new javax.swing.JToolBar();
          back = new javax.swing.JButton();
          jLabel1 = new javax.swing.JLabel();
          personalBackup = new javax.swing.JButton();
          personalRestore = new javax.swing.JButton();
          jLabel2 = new javax.swing.JLabel();
          backupSystem = new javax.swing.JButton();
          restoreSystem = new javax.swing.JButton();
  
          jToolBar1.setFloatable(false);
          jToolBar1.setRollover(true);
  
          back.setText("< Back");
          back.setFocusable(false);
          back.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
          back.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
          back.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  backActionPerformed(evt);
              }
          });
          jToolBar1.add(back);
  
          jLabel1.setText("Personal Files:");
  
          personalBackup.setText("Backup");
          personalBackup.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  personalBackupActionPerformed(evt);
              }
          });
  
          personalRestore.setText("Restore");
          personalRestore.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  personalRestoreActionPerformed(evt);
              }
          });
  
          jLabel2.setText("System Image:");
  
          backupSystem.setText("Backup");
          backupSystem.setEnabled(false);
          backupSystem.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  backupSystemActionPerformed(evt);
              }
          });
  
          restoreSystem.setText("Restore");
          restoreSystem.setEnabled(false);
          restoreSystem.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  restoreSystemActionPerformed(evt);
              }
          });
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
          this.setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addComponent(jLabel1)
                      .addComponent(jLabel2)
                      .addGroup(layout.createSequentialGroup()
                          .addGap(12, 12, 12)
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addGroup(layout.createSequentialGroup()
                                  .addComponent(backupSystem, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addComponent(restoreSystem, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
                              .addGroup(layout.createSequentialGroup()
                                  .addComponent(personalBackup, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addComponent(personalRestore, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                  .addContainerGap(218, Short.MAX_VALUE))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(jLabel1)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(personalBackup, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addComponent(personalRestore, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addGap(18, 18, 18)
                  .addComponent(jLabel2)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(backupSystem, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addComponent(restoreSystem, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addGap(0, 228, Short.MAX_VALUE))
          );
      }// </editor-fold>//GEN-END:initComponents
  
    private void personalBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_personalBackupActionPerformed
      BackupDialog dialog = new BackupDialog(null, true, true);
      if (dialog.nodest) {
        JF.showError("Error", "No media to backup to was detected!\nPlease insert a removable storage unit and try again.");
        return;
      }
      dialog.setVisible(true);
      if (!dialog.accepted) return;
      ArrayList<String> cmd = new ArrayList<String>();
      cmd.add("tar");
      cmd.add("c" + (dialog.getCompression() == 0 ? "z" : "j") + "fp");
      cmd.add(getDestFilename(dialog, true));
      cmd.add("-C");
      cmd.add(System.getenv("HOME"));
      cmd.add(".");
      cmd.add("--exclude=./.gvfs");
      cmd.add("--exclude=./.fuse");
      JFTask task = new JFTask() {
        private int current = 0, total = 0;
        private boolean finding;
        public boolean work() {
          String cmd[] = (String[])this.getProperty("cmd");
          ShellProcess sp = new ShellProcess();
          sp.addListener(this);
          sp.keepOutput(false);
          finding = true;
          this.setLabel("Determining # files");
          this.setProgress(-1);
          sp.run(new String[] {"find", System.getenv("HOME")}, false);
          this.setLabel("Backing up files");
          finding = false;
          sp.run(cmd, false);
  //        JFLog.log("cmd=" + sp.command);
          this.setLabel("Backup complete!");
          this.setProgress(100);
          return true;
        }
        public void shellProcessOutput(String str) {
          if (finding) {
            total += str.split("\n").length - 1;
          } else {
            current += str.split("\n").length - 1;
            this.setProgress(current * 100 / total);
          }
        }
      };
      task.setProperty("cmd", cmd.toArray(new String[0]));
      ProgressDialog pd = new ProgressDialog(null, true, task);
      pd.setVisible(true);
    }//GEN-LAST:event_personalBackupActionPerformed
  
    private void backupSystemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backupSystemActionPerformed
      BackupDialog dialog = new BackupDialog(null, true, false);
      if (dialog.nodest) {
        JF.showError("Error", "No media to backup to was detected!\nPlease insert a removable storage unit and try again.");
        return;
      }
      dialog.setVisible(true);
      if (!dialog.accepted) return;
      ArrayList<String> cmd = new ArrayList<String>();
      cmd.add("sudo");
      cmd.add("tar");
      cmd.add("c" + (dialog.getCompression() == 0 ? "z" : "j") + "fp");
      cmd.add(getDestFilename(dialog, false));
      cmd.add("-C");
      cmd.add("/");
      cmd.add(".");
      cmd.add("--exclude=/tmp");
      cmd.add("--exclude=/mnt");
      cmd.add("--exclude=/media");
      cmd.add("--exclude=/proc");
      cmd.add("--exclude=/sys");
      cmd.add("--exclude=/lost+found");
      JFTask task = new JFTask() {
        private int current = 0, total = 0;
        private boolean finding;
        public boolean work() {
          String cmd[] = (String[])this.getProperty("cmd");
          ShellProcess sp = new ShellProcess();
          sp.addListener(this);
          sp.keepOutput(false);
          finding = true;
          this.setLabel("Determining # files");
          this.setProgress(-1);
  