Global.helma.Ssh.execCommand (cmd)
executes a command on the remote server (scp must be in PATH on the remote server)

  • Parameter String:
    the command to execute
  • Returns
    String result of the command
Sourcecode in /home/hannes/helma/modules/helma/Ssh.js:
265:   this.execCommand = function(cmd) {
266:           if (!this.isConnected()) {
267:               error("execCommand", "Not connected. Please establish a connection first.");
268:           } else {
269:               var session = connection.openSession();
270:               try {
271:                   session.execCommand(cmd);
272:                   var stdout = new SSHPKG.StreamGobbler(session.getStdout());
273:                   var br = new java.io.BufferedReader(new java.io.InputStreamReader(stdout));
274:                  res.push();
275:      			while (true) {
276:      				if (!(line = br.readLine()))
277:      					break;
278:      				res.writeln(line);
279:      			}
280:                  debug("execCommand", "executed command '" + cmd + "'");
281:                  return res.pop();
282:              } catch (e) {
283:                  error("execCommand", e);
284:              } finally {
285:                  session.close();
286:              }
287:          }
288:      }