1 package net.sf.tomp.xtcl.command;
2
3 import net.sf.tomp.xtcl.Context;
4
5 /***
6 * Executes an XTCL-external, i.e. OS/based command.
7 *
8 * @author tomp
9 */
10 public class ExeCommand extends AbstractCommand {
11
12 /*** array holding cmd name and params */
13 protected String[] cmdarray;
14
15 /***
16 * set the array holding cmd name and params
17 *
18 * @param r array holding cmd name and params
19 */
20 public void setCmdArray(String[] r) {
21 cmdarray = r;
22 }
23
24 /***
25 * execute the external command with params
26 *
27 * @param c Context
28 * @return DOCUMENT ME!
29 * @throws Exception DOCUMENT ME!
30 */
31 public int execute(Context c) throws Exception {
32 int retCode;
33
34 try {
35 Runtime rt = Runtime.getRuntime();
36 Process p = rt.exec(cmdarray);
37
38 retCode = p.exitValue();
39 } catch (Exception e) {
40 retCode = 1;
41 }
42
43 return done(c, retCode);
44 }
45
46 /***
47 * @return "RUN " + listArray(cmdarray);
48 */
49 public String toString() {
50 return "RUN " + listArray(cmdarray);
51 }
52 }
53
54
55
56
57
58
59
60
61
62
63