org.browsecode.helpers.controlcomputer.ssh
Class J2SSHInterface
java.lang.Object
org.browsecode.helpers.controlcomputer.ssh.SSHInterface
org.browsecode.helpers.controlcomputer.ssh.J2SSHInterface
- All Implemented Interfaces:
- ControlComputerInterface
public class J2SSHInterface
- extends SSHInterface
Method Summary |
boolean |
authenticateOnly(java.lang.String thost,
java.lang.String tuserID,
java.lang.String tpassword,
SSHProgressListener listenToProgress)
|
protected void |
closeConnection()
|
boolean |
copyTo(java.io.File[] files,
java.lang.String toDir)
|
boolean |
didLastMySQLCommandInclude(java.lang.String name)
|
void |
dispose()
|
java.lang.String |
getAllOutput()
|
java.util.Vector |
getAllOutputAsVector()
|
java.lang.String |
getAllSSHLinesWithLineNumbers()
|
java.lang.String |
getDirectorySeparator()
Usually this is '\' for Windows and '/' for everything else. |
java.lang.String |
getHostname()
|
int |
getOperatingSystem()
Operating System Checks may or may not be implemented. |
java.lang.String |
getOSVersion()
|
java.lang.String |
getTempDirectory()
Get a path for temporary files. |
int |
getUnixVariant()
|
boolean |
isDoneCopying()
|
boolean |
isStillRunningLastCommand()
|
void |
restart()
|
boolean |
runCommand(java.lang.String line)
|
ControlComputerInterface.SearchForFile |
searchForFile(ControlComputerInterface.FileMatches fileMatches,
ControlComputerInterface.ConfirmationHandler confirmationHandler,
java.lang.Runnable runWhenDone)
This may return null if it's not possible to search for files on this operating system. |
java.lang.String |
start(java.lang.String host,
java.lang.String userID,
java.lang.String password,
SSHProgressListener listenToProgress)
|
java.lang.String |
startShellAfterAuthentication()
|
boolean |
uploadFileViaFTP(java.lang.String filename,
java.io.File file)
Backup technique in case the ssh scp doesn't work. |
int |
waitForResponse(java.lang.String[] waitFor)
|
boolean |
willSpecialUnixCharactersBeConverted()
On bash and other unix/linux shells, certain characters get changed to do something else besides themselves:
- exclamation points get turned into old commands on the command prompt |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
J2SSHInterface
public J2SSHInterface()
getHostname
public java.lang.String getHostname()
getOperatingSystem
public int getOperatingSystem()
- Description copied from interface:
ControlComputerInterface
- Operating System Checks may or may not be implemented. (i.e. it works with local controls but not over SSH, at least not yet)
- Returns:
getUnixVariant
public int getUnixVariant()
getOSVersion
public java.lang.String getOSVersion()
getDirectorySeparator
public java.lang.String getDirectorySeparator()
- Description copied from interface:
ControlComputerInterface
- Usually this is '\' for Windows and '/' for everything else.
- Returns:
getTempDirectory
public java.lang.String getTempDirectory()
- Description copied from interface:
ControlComputerInterface
- Get a path for temporary files.
- Returns:
authenticateOnly
public boolean authenticateOnly(java.lang.String thost,
java.lang.String tuserID,
java.lang.String tpassword,
SSHProgressListener listenToProgress)
- Specified by:
authenticateOnly
in class SSHInterface
startShellAfterAuthentication
public java.lang.String startShellAfterAuthentication()
start
public java.lang.String start(java.lang.String host,
java.lang.String userID,
java.lang.String password,
SSHProgressListener listenToProgress)
- Specified by:
start
in class SSHInterface
restart
public void restart()
dispose
public void dispose()
closeConnection
protected void closeConnection()
runCommand
public boolean runCommand(java.lang.String line)
- Specified by:
runCommand
in interface ControlComputerInterface
- Specified by:
runCommand
in class SSHInterface
uploadFileViaFTP
public boolean uploadFileViaFTP(java.lang.String filename,
java.io.File file)
- Backup technique in case the ssh scp doesn't work. Specifically for use with JavaServletHosting's wierd setup.
Too bad this one isn't as secure...
- Parameters:
filename
- file
-
- Returns:
getAllOutput
public java.lang.String getAllOutput()
- Specified by:
getAllOutput
in interface ControlComputerInterface
- Specified by:
getAllOutput
in class SSHInterface
- Parameters:
find
- lineToStartOn
- characterOnLine
-
- Returns:
- Vector -- a tuple of two Integers -- the line it found and the character that the text starts at
getAllOutputAsVector
public java.util.Vector getAllOutputAsVector()
- Specified by:
getAllOutputAsVector
in class SSHInterface
getAllSSHLinesWithLineNumbers
public java.lang.String getAllSSHLinesWithLineNumbers()
isStillRunningLastCommand
public boolean isStillRunningLastCommand()
waitForResponse
public int waitForResponse(java.lang.String[] waitFor)
- Specified by:
waitForResponse
in interface ControlComputerInterface
- Specified by:
waitForResponse
in class SSHInterface
copyTo
public boolean copyTo(java.io.File[] files,
java.lang.String toDir)
- Specified by:
copyTo
in interface ControlComputerInterface
- Specified by:
copyTo
in class SSHInterface
isDoneCopying
public boolean isDoneCopying()
- Specified by:
isDoneCopying
in class SSHInterface
didLastMySQLCommandInclude
public boolean didLastMySQLCommandInclude(java.lang.String name)
- Specified by:
didLastMySQLCommandInclude
in class SSHInterface
willSpecialUnixCharactersBeConverted
public boolean willSpecialUnixCharactersBeConverted()
- Description copied from interface:
ControlComputerInterface
- On bash and other unix/linux shells, certain characters get changed to do something else besides themselves:
- exclamation points get turned into old commands on the command prompt.
- > and >> will write to the file mentioned after this point
- | will pipe to a new command
Some ControlComputerInterfaces have this property (like SSH) and others don't (like ControlThisComputer, even on linux).
Calling method needs to know in case it tries to do 'echo "Hi!" ' or or 'echo "test" >> file' -- both will fail on ones where this method returns false, and work on ones where this methods return true.
It's hard to pull this out in a standard way and do something better.
searchForFile
public ControlComputerInterface.SearchForFile searchForFile(ControlComputerInterface.FileMatches fileMatches,
ControlComputerInterface.ConfirmationHandler confirmationHandler,
java.lang.Runnable runWhenDone)
- Description copied from interface:
ControlComputerInterface
- This may return null if it's not possible to search for files on this operating system.
- Returns: