Why does this not work?

Hi All,
Take the following test code:
      1 import java.io.*;
      2
      3 public class GetFsSpace {
      4
      5     private String[] cmd = {"df"};
      6
      7     public static void main(String[] args) {
      8         GetFsSpace fs = new GetFsSpace();
      9         fs.runCmd();
     10     }
     11
     12     public void runCmd() {
     13
     14         try {
     15             Runtime rt = Runtime.getRuntime();
     16             Process proc = rt.exec(cmd);
     17             InputStream stdout = proc.getInputStream();
     18             InputStreamReader isr = new InputStreamReader(stdout);
     19             BufferedReader br = new BufferedReader(isr);
     20             String line = null;
     21             System.out.println("<Starting output.>");
     22
     23             while ( (line = br.readLine()) != null) {
     24                 System.out.println(line);
     25             }
     26
     27         } catch (Throwable t) {
     28             t.printStackTrace();
     29         }
     30     }
     31 }Now, this compiles and works fine, however, if I change the String in line 5 to read:
private String[] cmd = {"df -k"};It throws an exception. So it's obviously to do with the string and I'm probably missing the obvious here, but can someone point me in the right direction?
many thanks
Doug.

appologies, here's the exception I get when I run it:
java -cp . GetFsSpace
java.io.IOException: java.io.IOException: df -k: not found
        at java.lang.UNIXProcess.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at GetFsSpace.runCmd(GetFsSpace.java:16)
        at GetFsSpace.main(GetFsSpace.java:9)and this only happens when I add the "-k" option to df.
thanks.

Similar Messages

  • CTRL+P requires manual tab focus when printing a PDF within FF4. This worked fine in FF3. Why does it not work any more? Thanks!

    Hi,
    CTRL+P requires manual tab focus when printing a PDF within FF4. This worked fine in FF3 - i.e, you could just select the tab. Why does it not work any more? Thanks!

    Hi
    https://discussions.apple.com/thread/4325038?tstart=0
    CCT

  • Why does Firefox not work here in China anymore, since January of 2015?

    I have used Firefox for years, as the fastest and most reliable browser for me, esp in China... not anymore! Last month (unknown to me) a hijacker called Vosteran took over my Firefox browser. I finally realized it and got it cleaned up using Malwarebytes anti-malware, and downloaded a new Firefox... now SAME problem exists, even with Vosteran removed!
    Firefox will not allow me into ANY normal sites, saying they don't have the proper security code. This includes my Yahoo front page, email account, ESPN and other common sites that are certainly NOT dangerous. So, WHY does Firefox not work anymore? It is useless to me here in China the way it works now.

    hello rickinchina, first please make sure that the '''date, time & timezone''' are set correctly on your system and that firefox is set to directly connect to the internet (that's the "'''no proxy'''" setting in the firefox ''menu ≡ > options > advanced > network > connection - settings...'').
    if this doesn't solve the issue (or it is already set properly), a possible solution depends on different factors:
    * what is the '''error code''' shown under ''technical details'' on the error page?
    in case the error code equals ''sec_error_unknown_issuer'', please attempt to add an exception on the bottom of the error page (but don't do it for real) and inspect the certificate (see the screenshot attached for instructions):
    * which '''issuer information''' does the certificate contain?
    please report back with those two pieces of information. thank you!

  • Why does abode not work on my galaxy tab2

    Why does abode not work on my galaxy tab 2?

    The games dont load they just say I need to update to the latest version or say that it is not compaterble with it.

  • Why does sound not work on my Mac Air?

    Why does sound not work on my Mac Air --all setting seem okay. OSX 10.9.2 operating systyem.

    Open System Preferences > Sound > Output
    Make sure the coorect output devices is selected and the Mute button is not checked.

  • HT202853 I have many project made in move HD that are not updating to the new iMovie 10 on my new iMac.  Why is this not working as stated?  How do I get my projects back from backup after old iMac crashed?

    I have many projects made in imovie HD that are not updating to iMovie 10 on my new iMac.  Why is this not working as stated on the article HT202853?  How do I get my projects back from backup after old iMac crashed?

    According to:
    Update projects and events from previous versions of iMovie in iMovie (2014) - Apple Support
    you can update from iMovie versions 7, 8 and 9, but iMovie HD is iMovie 6.
    Maybe you can update in two steps, first from iMovie 6 to iMovie 7, 8 or 9 then to iMovie 10. 
    Geoff.

  • After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    We can't know anything. You have not provided any useful details like system information or the install logs.
    Mylenium

  • Why does iMessenger not work/takes ages to load?

    Why does iMessenger not work/takes ages to load?
    - done all the log in stuff (username and display name but then takes for ever to load so just give up!

    How has it stopped working?
    ARe you on wifi or cellular data?

  • HT1848 How do I sync my music on my computer to my iPhone - why does this not happen automatically when I connect?

    How do I sync my music on my computer to my iPhone - why does this not happen automatically when I connect?

    Do you have iTunes set to sync music to the device?
    Have you read the User's Guide that explains how to use the device?
    Syncing media and content to iDevices

  • "Exit" Button to destroy Xlet-why does it not work???

    Hey there!
    I am very confused with KeyEvents in MHP and kind of stuck..
    I just want an EXIT Button for my Xlet-that's all!! I tried to different ways:
    The first one is compiling without any errors but it just does not work, either in XletView 3.6 nor in the IRT Implementation..Is there something i missed?
    Here is (a piece of) my first code:
    public void keyPressed (java.awt.event.KeyEvent KeyEvent) {
    int key = KeyEvent.getKeyCode();
    if (KeyEvent.getSource() == butt1 && key == HRcEvent.VK_ENTER)
    try {
    destroyXlet(true);
    catch (XletStateChangeException ex){
    butt1 is the "Exit" Button.
    I also tried this Code using the dvb UserEvent and UserEventRepository which worked pretty well with XletView, but failed when testing it with the IRT..
    public void userEventReceived(org.dvb.event.UserEvent userEvent) {
    int key = userEvent.getCode();
    if (userEvent.getSource() == butt1)
    if ( key == HRcEvent.VK_ENTER){
    try{
    destroyXlet(true);
    catch (XletStateChangeException ex){
    Why does this one not work with the IRT-Implementation?? Nothing happens at all when pressing ENTER on the RC..
    Has somebody an idea or fixed out which kind of mistake i made?
    As i said i am really stuck and i had a look at many examples, but nothing worked at all!!

    Hello Steve!
    Unfortunately your suggestion did not work too..
    I added context.notifyDestroyed() to destroyXlet(), the problem is that my application does not react on pressing VK_ENTER..
    Do you have any other ideas?
    The second code with dvb events just works without adding notifyDestroyed,
    but just with XletView, not with the IRT RI..

  • HT2470 Why does this not explain how to change the sort order?

    Why does this (i.e. support at Apple.com) not explain how to change the sort order? I can "arrange" by Date Modified for example but it won't let me switch to use most recent dates first. Also, what is Apple-speak for arrange versus sort anyway? It seems I used to be able to click on a column heading in finder and get a drop down arrow allowing me to change the sort sequence.

    Arrange roughly translates to "group the items in the folder." Sort is how each group is ordered. If you have arrange set to none, you can sort by anything. However, there is no way in the Arrange/Sort menu to choose the direction. The only way to do that is in the List View, and you must have Arrangement set to None.
    I've submitted an Enhancement Request to allow choosing sort direction from the Arrange/Sort menu, but I haven't ever gotten a response, which is good and bad. Good because they will often respond that they have considered it and don't plan on implementing. Bad in that they've haven't implemented it.

  • Why Does 3G Not Work on my IPhone

    Apologies everyone - I am a real numpty with my IPhone.  I have switched just about everything on i think I need to to enable 3G and my service provider says that in my present location the wireless service is excellent.  So why is that on my top toolbar I don't see 3G - just my signal strength, service provider and a round circle then the date.  I cannot get connectivity unless I am at home next to my own router.  Can anyone help as I have had this problem now since I have had my phone and I really do need to get it sorted out.  Any guidance at all is very welcome indeed.

    Hi,
    What type of iPhone do you have. I heard that 3G cannot switched off on an iPhone 4s, so if you have that one, it can only be a service provider issue (worst case: Your antenna does not work).
    Did you try on a different location, like downtown?
    If you have an iPhone 4 or 3Gs you can check if 3G is switched off: Go to settings->General->Network. At the top there is a 3G switch that should be on (blue).
    Let us know if this works.

  • Problem: Why does this only work for powers of 2?

    I wrote this program to create a golf league schedule for, ideally, eight players. However I want it to be flexible enough to permit for other denominations, such as 10 or 12. When I run the program it works perfectly for any number that is a power of 2 (2,4,8,16,32,etc...) but it will not work for other even numbers such as 6,10, or 12. If anyone has any insights it would be most helpful.
    *(This is my first post on this forum so if anything looks not quite right or if this post isn't worded exactly how it should be then I apologize in advance)*
    Here's the three classes.
    public class ScheduleDriver
         public static void main(String[] args)
                              //instance variables
              int max;     //size of flight matches array
              ScheduleMaster master;//instance of class
              //get max number of players for flight
              System.out.print("Max number of players in this flight:");
              max = Keyboard.readInt();
              master = new ScheduleMaster(max);
              //create weekly schedules for season
              master.createSchedule();
              //display weekly schedules
              master.displayWeekly();
         }//end main
    }//end ScheduleDriver
    public class ScheduleMaster
         //instance variables
         int maxPlyrs;//maximum number of players in flight
         Week[] weeklySchedule;//array of weekly matches
         public ScheduleMaster(int plyrs)
              //set up instance data and declare array size
              maxPlyrs = plyrs;
              weeklySchedule = new Week[plyrs];
              //set up the size of each week's matches array
              for (int pos = 0; pos < plyrs; pos++)
                   weeklySchedule[pos] = new Week(plyrs);
              }//end for
         }//end constructor
         public void createSchedule()
              int count = 0;//index of weeklySchedule array
              final int QUIT = -1;     //quit value for loop
              int flag = 0;     //value to continue or exit loop
              //for each player A
              for (int a = 1; a < maxPlyrs; a++)
                   //for each opponent of player A
                   for (int b = (a + 1); b <=maxPlyrs;b++)
                        //set count/index and       reset flag to zero
                        count = (a - 1);
                        flag = 0;
                        //while still haven't found correct week for this match
                        while (flag != QUIT)
                             //if at least one of these players are already scheduled
                             //for a match this week
                             if (weeklySchedule[count].checkPlayers(a,b) == true)
                                  //if last valid index of array has been reached
                                  if (count == (maxPlyrs - 2))
                                       //reset count/index to zero
                                       count = 0;
                                  else
                                       //incriment count
                                       count++;
                             }//end if
                             else
                                  //assign this match to array of matches for week
                                  //and then exit loop
                                  weeklySchedule[count].setMatch(a,b);
                                  flag = -1;
                             }//end else
                        }//end while
                   }//end for
              }//end for
              //fill in last week/position night
              for (int pos = 0; pos < maxPlyrs;pos++)
                   //set up position match
                   weeklySchedule[maxPlyrs - 1].setMatch(pos + 1, pos + 2);
                   //incriment pos
                   pos++;
              }//end for
         }//end createSchedule
         public void displayWeekly()
              //for each week in schedule
              for (int pos = 0; pos < maxPlyrs;pos++)
                   //display header
                   System.out.print("WEEK " + (pos + 1));
                   //if pos/index is 0 or even, flight plays front 9
                   if ((pos % 2) == 0)
                        System.out.println(" [FRONT 9]");
                   //else flight plays back 9
                   else
                        System.out.println(" [BACK 9]");
                   //display lines
                   System.out.println("----------------");
                   //display week's matches
                   weeklySchedule[pos].display();
                   //skip a line
                   System.out.println("\n");
              }//end for
         }//end displayWeekly
    }//end ScheduleMaster
    public class Week
         int[] schedule;          //array of players involved in matches for week
         int max;               //max number of players
         int count = 0;          //number of players currently involved in matches
         public Week(int size)
              //set up instance data and size of array
              max = size;
              schedule = new int[size];
         }//end constructor
         public boolean checkPlayers(int playerA, int playerB)
              boolean flag = false;     //flag to determine if at least one of
                                            //the players to check are already playing
                                            //this week
              //for each element of array
              for (int pos = 0; pos < max; pos++)
                   //if player A matches player already playing this week
                   if (schedule[pos] == playerA)
                        flag = true;
              }//end for
              //for each element of array
              for (int pos = 0; pos < max; pos++)
                   //if player B matches player already playing this week
                   if (schedule[pos] == playerB)
                        flag = true;
              }//end for
              return flag;
         }//end checkPlayers
         public void setMatch(int playerA, int playerB)
              //if array can take more matches
              if (count <= (max - 2))
                   //insert players into array of active players for week
                   schedule[count] = playerA;
                   schedule[count + 1] = playerB;
                   //incriment count of players playing this week by 2
                   count = count + 2;
              }//end if
              else
                   System.out.print("No more matches can be entered!!!");
         }//end setMatch
         public void display()
              //for every even numbered index starting at zero
              for (int num = 0;num < max;num++)
                   //display the player at that position and the next consecutive
                   //player who will be his opponent for the week
                   System.out.println(schedule[num] + "VS" + schedule[num + 1] +
                   //incriment num
                   num++;
              }//end for
         }//end display
    }//end Week

    Ah, I have discovered the problem. The reason for the infinite loop was because of the resetting of the counter/index after every successful match entry back to (a - 1). This was causing matches to be put into weeks where they didn't belong, which caused the program to infinitely loop because it couldn't find an appropriate week to place it's next match. The only time the count should be reset back to zero is when a new player A is being processed or the last valid array index has been referenced before an out of bounds exception would be thrown. I'm still not entirely sure why this doesn't occur on powers of 2 but theh again I haven't put too much thought into it having solved the initial problem! :)
    Anyways thanks for the input all who posted, much appreciated.
    Happy programming!!!!

  • Why does Thunderbird not work with Windows 8.1

    I have used thunderbird now for about 6 years, for all my website accounts. During that time I have had very few problems, about 9 months ago I started using Windows 8, I transferred all my accounts from my old machines running on XP pro to new machines running Win 8 and thunderbird ran ok. I have auto updates running so I am assuming both thunderbird and windows are updating whenever! About 4 weeks ago I started experiencing major problems with Thunderbird, it would start then freeze, then it would start again then freeze, if I ran it in safe mode it would work for a while. Now it opens and freezes, the message at the top just says ' Thunderbird is not responding'. Even in safe mode now it will not work! I have tried uninstalling and re-installing, I have even tried installing an earlier version of Thunderbird, I Have deleted the profile and forced it to produce a new one, I have spent hours trawling different sites trying to find an answer, and you know what, the only conclusion I could come to was, nobody seems to care whether this problem is solved or not, so reluctantly I have had to give up and I moved all my accounts to Outlook, which works perfectly with Windows 8.1. I think that should have been the answer, right from the start of the problem!

    The point is, it shouldn't matter if you're using McAffee or Norton or not using any anti-virus at all. Thunderbird works on XP. Thunderbird works on Vista. Thunderbird works on 7. But despite what the FAQ says, Thunderbird does _NOT_ work on Windows 8. This is a problem that many people are having and Mozilla _OUGHT_ to be able to fix it.
    I hate to bitch because Thunderbird is free and it's a damned good program. But this damned good program that worked through three earlier iterations of MicroSoft operating systems is unusable on 8.1. Anybody who has any knowledge of user experience can tell you that a program becoming unresponsive at random for anywhere from 1 to 3 minutes is simply not acceptable.
    This problem has been known for quite some time now. Is anybody in Mozilla support even looking at it?

  • PSE11 Why does Sharpening not work in Quick or Guided Mode?

    I have used PSE 5 happily and greatly liked the auto sharpen feature. I have been forced to upgrade to PSE 11 due to Windows 8 incompatibility with 5.
    I am appalled to find that the sharpen feature, including auto, does not work in Quick or Guided modes. The small previews in Quick mode show the correct sharpening effect but clicking on them or using the slider does not transfer to the main image. I either have to go into full unsharp mask, which I hate for quick fixes, or use the 'adjust sharpness' option under 'filter' in Quick or Guided Mode, which increases sharpness by an unspecified amount on each click.
    Surely there si something wrong here. The feature is there so why doesn't it work?
    Any ideas would be welcome. If it isn't fixable I shall want a refund based on the product not being fit for purpose.
    Thanks
    dlgoodyear

    Thanks for confirming that it should work ok. I've now done the obvious and uninstalled/reinstalled and it's fine now.
    Dave

Maybe you are looking for