blob: d6f654eb2e0d4d645aa4e766495f5511e0cb2269 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Verify we can modify the environment.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;
public class Process_7
{
public static void main(String[] args)
{
try
{
ProcessBuilder pb = new ProcessBuilder("env");
Map<String, String> e = pb.environment();
e.clear();
String v = "process7_value";
String k = "PROCESS_7_KEY";
e.put(k, v);
Process p = pb.start();
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
boolean found = false;
String result;
while ((result = br.readLine()) != null)
{
if (result.equals(k + '=' + v))
found = true;
}
if (!found)
{
System.out.println("bad");
return;
}
System.out.println("ok");
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
}
}
|