Difference between revisions of "PluginConnectivityExamples"

From Autodrive
Jump to: navigation, search
(Create a ssh session)
Line 4: Line 4:
  
 
==Create a ssh session==
 
==Create a ssh session==
 +
 +
On linux and unix only root can bind ports below 1024. This can be remedied in a number of ways. E.g. by setting capabilities on the java executable or by using some suitable NAT rule.
  
 
  <nowiki>
 
  <nowiki>
Line 16: Line 18:
 
   theObj = getPlugin(Packages.dk.autodrive.plugins.AD_Connectivity_Commands);
 
   theObj = getPlugin(Packages.dk.autodrive.plugins.AD_Connectivity_Commands);
  
 +
  // Using default ssh port 22
 
   theObj.createSSHSession('ipaddress','username','password');
 
   theObj.createSSHSession('ipaddress','username','password');
 
   var result = theObj.shellSend('whoami');
 
   var result = theObj.shellSend('whoami');
 +
 +
  // Using custom ssh port 2222
 +
  theObj.createSSHSession('ipaddress',2222,'username','password');
 +
  result = theObj.shellSend('whoami');
 
ENDSCRIPT</nowiki>
 
ENDSCRIPT</nowiki>
  

Revision as of 11:00, 15 June 2013

Connectivity examples

This section collects common examples. Connectivity is actual two plugins one for handling ssh and telnet and one for handling ftp.

Create a ssh session

On linux and unix only root can bind ports below 1024. This can be remedied in a number of ways. E.g. by setting capabilities on the java executable or by using some suitable NAT rule.

/*
 * Connect to ipaddress and store result of executing whoami on the remote host
 */
SCRIPT:javascript
  importPackage( Packages.dk.autodrive.base );
  importPackage( Packages.dk.autodrive.plugins );

  var f = ''+at.loadJS("stdfunc.js"); eval(f);
  theObj = getPlugin(Packages.dk.autodrive.plugins.AD_Connectivity_Commands);

  // Using default ssh port 22
  theObj.createSSHSession('ipaddress','username','password');
  var result = theObj.shellSend('whoami');

  // Using custom ssh port 2222
  theObj.createSSHSession('ipaddress',2222,'username','password');
  result = theObj.shellSend('whoami');
ENDSCRIPT

Connect to jumpserver

ToDo, complete examples.

SCRIPT:javascript
  importPackage( Packages.dk.autodrive.base );
  importPackage( Packages.dk.autodrive.plugins );

  var f = ''+at.loadJS("stdfunc.js"); eval(f);
  theObj = getPlugin(Packages.dk.autodrive.plugins.AD_Connectivity_Commands);

  theObj.jumpServerConnect('username','password','jumpserveripaddress');
ENDSCRIPT

Connect to a remote host

Portforwarding

Setting up a http proxy

Setting up a socks proxy

Socket timeout

Command timeout

Telnet

FTP

sFTP

FTPs