title: Android: Runtime exec() gives null environment?
body: <p>I am trying to run the following command in Runtime exec():</p>
  
  <pre><code>Process p;
  try {
      p = Runtime.getRuntime().exec("arp -a");
      BufferedReader in = new BufferedReader(
              new InputStreamReader(p.getInputStream()));
  
      String inputLine;
      while ((inputLine = in.readLine()) != null) {
          if (!inputLine.contains("incomplete")) {
  
              found++;
              inputLine = cleanResult(inputLine);
              storeList(inputLine);
          }
      }
      in.close();
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      Log.e("check",e.getMessage());
  }
  </code></pre>
  
  <p>And the error that I'm getting is:</p>
  
  <pre><code>    07-14 12:23:16.548: W/System.err(14272): java.io.IOException: Error running exec(). Command: [arp, -n] Working Directory: null Environment: null
  07-14 12:23:16.668: W/System.err(14272):    at java.lang.ProcessManager.exec(ProcessManager.java:211)
  07-14 12:23:16.668: W/System.err(14272):    at java.lang.Runtime.exec(Runtime.java:168)
  07-14 12:23:16.668: W/System.err(14272):    at java.lang.Runtime.exec(Runtime.java:241)
  07-14 12:23:16.668: W/System.err(14272):    at java.lang.Runtime.exec(Runtime.java:184)
  07-14 12:23:16.678: W/System.err(14272):    at com.app.president.FindDevices$8.run(FindDevices.java:225)
  07-14 12:23:16.678: W/System.err(14272):    at android.os.Handler.handleCallback(Handler.java:725)
  07-14 12:23:16.678: W/System.err(14272):    at android.os.Handler.dispatchMessage(Handler.java:92)
  07-14 12:23:16.678: W/System.err(14272):    at android.os.Looper.loop(Looper.java:137)
  07-14 12:23:16.678: W/System.err(14272):    at android.app.ActivityThread.main(ActivityThread.java:5099)
  07-14 12:23:16.678: W/System.err(14272):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-14 12:23:16.678: W/System.err(14272):    at java.lang.reflect.Method.invoke(Method.java:511)
  07-14 12:23:16.678: W/System.err(14272):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803)
  07-14 12:23:16.678: W/System.err(14272):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
  07-14 12:23:16.678: W/System.err(14272):    at dalvik.system.NativeStart.main(Native Method)
  07-14 12:23:16.678: W/System.err(14272): Caused by: java.io.IOException: Permission denied
  07-14 12:23:16.678: W/System.err(14272):    at java.lang.ProcessManager.exec(Native Method)
  07-14 12:23:16.678: W/System.err(14272):    at java.lang.ProcessManager.exec(ProcessManager.java:209)
  07-14 12:23:16.688: W/System.err(14272):    ... 13 more
  </code></pre>
  
  <p>The LOG that I have put for check reads:</p>
  
  <pre><code>07-14 12:23:19.971: E/check(14272): Error running exec(). Command: [arp, -a] Working Directory: null Environment: null
  </code></pre>
  
  <p>What this code does is, it tries to read the arp cache to fetch all MAC address with their respective IP addresses. </p>
  
  <p>Can someone please help me with this and get my code running. I want to know why is the following code giving this error? Are there any permissions required for doing this? The permission I have granted till now are:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>
  
  <p>Thanks in advance :)</p>