Documentation ¶
Index ¶
- Constants
- func ExecuteCommand(command string) (output string, err error)
- func ExecuteCommandAndWait(command string) (output string, err error)
- func ExecuteCommandNoWait(command string) (output string, err error)
- func GetDefaultIP() (ip string, err error)
- func GetFileNameDest(fileNameSource, dirDest string) string
- func GetPathDirMapLocal(pathDirMap map[string]string, dirName, rootPath string) (err error)
- func GetPidFromPidFile(pidFile string) (int, error)
- func HandleSignalsWithPidFile(pidFile string)
- func IsDir(path string) (isDir bool, err error)
- func IsEmptyDir(dirName string) (isEmpty bool, err error)
- func IsRunningWithPid(pid int) (bool, error)
- func IsRunningWithPidFile(pidFile string) (bool, error)
- func KillServer(pid int, opts ...string) (err error)
- func KillServerWithSignal(pid, signal int, opts ...string) error
- func PathExists(path string) (bool, error)
- func Readdir(dirName string) (fileInfoList []os.FileInfo, err error)
- func RemovePidFile(pidFile string) error
- func SavePid(pid int, pidFile string, fileMode os.FileMode) error
- func SyscallMode(fileMode os.FileMode) (fileModeSys uint32)
- func TailN(fileName string, n int) (lines []string, err error)
- type MyConn
- type MySSHConn
- func (conn *MySSHConn) Close() (err error)
- func (conn *MySSHConn) CopyDirFromRemote(dirNameSource, dirNameDest string) (err error)
- func (conn *MySSHConn) CopyDirToRemote(dirNameSource, dirNameDest string) (err error)
- func (conn *MySSHConn) CopyFile(fileSource io.Reader, fileDest io.Writer, bufferSize int) (err error)
- func (conn *MySSHConn) CopyFileListFromRemote(fileListSource []string, FileDirDest string) (err error)
- func (conn *MySSHConn) CopyFileListFromRemoteWithNewName(fileListSource []string, FileListDest []string) (err error)
- func (conn *MySSHConn) CopyFromRemote(pathSource, pathDest string) (err error)
- func (conn *MySSHConn) CopySingleFileFromRemote(fileNameSource string, fileNameDest string) (err error)
- func (conn *MySSHConn) CopySingleFileToRemote(fileNameSource string, fileNameDest string) (err error)
- func (conn *MySSHConn) CopyToRemote(pathSource, pathDest string) (err error)
- func (conn *MySSHConn) ExecuteCommand(cmd string) (output string, err error)
- func (conn *MySSHConn) GetHostName() (hostName string, err error)
- func (conn *MySSHConn) GetPathDirMapRemote(fileDirMap map[string]string, dirName, rootPath string) (err error)
- func (conn *MySSHConn) IsDir(path string) (isDir bool, err error)
- func (conn *MySSHConn) IsEmptyDir(dirName string) (isEmpty bool, err error)
- func (conn *MySSHConn) ListPath(path string) (subPathList []string, err error)
- func (conn *MySSHConn) PathExists(path string) (bool, error)
- func (conn *MySSHConn) ReadDir(dirName string) (fileInfoList []os.FileInfo, err error)
- func (conn *MySSHConn) RemoveAll(path string) (err error)
Constants ¶
const ( HostNameCommand = "hostname" LsCommand = "ls" DefaultEstimateLineSize = 1024 MinStartPosition = 0 )
const ( DefaultSplitStr = "\n" DefaultStringZeroValue = "" DefaultSuccessReturnValue = 0 DefaultFailedReturnValue = 1 DefaultSSHTimeout = 10 * time.Second DefaultSSHPortNum = 22 DefaultSSHUserName = "root" DefaultSSHUserPass = "root" DefaultByteBufferSize = 1024 * 1024 // 1MB )
Variables ¶
This section is empty.
Functions ¶
func ExecuteCommand ¶ added in v0.1.4
ExecuteCommand is an alias of ExecuteCommandAndWait
func ExecuteCommandAndWait ¶ added in v0.1.20
ExecuteCommandAndWait executes shell command and wait for it to complete
func ExecuteCommandNoWait ¶ added in v0.1.20
ExecuteCommandNoWait executes shell command and does not wait for it to complete
func GetDefaultIP ¶
GetDefaultIP get a default non local ip, err is not nil, ip return 127.0.0.1
func GetFileNameDest ¶ added in v0.1.4
GetFileNameDest returns the destination file name
func GetPathDirMapLocal ¶ added in v0.1.5
GetPathDirMapLocal reads all subdirectories and files of given directory and calculate the relative path of rootPath, then map the absolute path of subdirectory names and file names as keys, relative paths as values to fileDirMap
func GetPidFromPidFile ¶ added in v0.1.17
GetPidFromPidFile reads pid file and returns pid
func HandleSignalsWithPidFile ¶ added in v0.1.15
func HandleSignalsWithPidFile(pidFile string)
HandleSignalsWithPidFile handles operating system signals
func IsEmptyDir ¶ added in v0.1.4
IsEmptyDir returns if given directory is empty or not
func IsRunningWithPid ¶ added in v0.1.15
IsRunningWithPid returns if given pid is running
func IsRunningWithPidFile ¶ added in v0.1.15
IsRunningWithPidFile returns if process of which pid was saved in given pid file is running
func KillServer ¶ added in v0.1.18
KillServer kills process with given pid, it will also remove pid file if pid file path is specified as opts
func KillServerWithSignal ¶ added in v0.1.19
KillServerWithSignal kills process with given pid and signal, it will also remove pid file if pid file path is specified as opts, as this function accepts signal as argument, it is only worked on unix-like system
func PathExists ¶ added in v0.1.5
PathExists returns if given path exists
func Readdir ¶ added in v0.1.4
ReadDir returns subdirectories and files of given directory on the remote host, it returns a slice of os.FileInfo
func RemovePidFile ¶ added in v0.1.19
func SyscallMode ¶ added in v0.1.4
SyscallMode returns file mode which could be used at syscall
Types ¶
type MyConn ¶ added in v0.1.4
func NewMyConnWithDefaultValue ¶ added in v0.1.4
type MySSHConn ¶ added in v0.1.4
func NewMySSHConn ¶ added in v0.1.4
NewMySSHConn returns *MySSHConn and error
func NewMySSHConnWithOptionalArgs ¶ added in v0.1.4
NewMySSHConnWithOptionalArgs returns *MySSHConn and error, first argument is mandatory which presents host ip, and the 3 flowing optional arguments which should be in exact order of port number, user name and user password
func (*MySSHConn) CopyDirFromRemote ¶ added in v0.1.4
CopyDirFromRemote copies a directory with all subdirectories and files from remote to local
func (*MySSHConn) CopyDirToRemote ¶ added in v0.1.4
CopyDirFromRemote copies a directory with all subdirectories and files from local to remote
func (*MySSHConn) CopyFile ¶ added in v0.1.4
func (conn *MySSHConn) CopyFile(fileSource io.Reader, fileDest io.Writer, bufferSize int) (err error)
CopyFile copy file content from source to destination, it doesn't care about which one is local or remote
func (*MySSHConn) CopyFileListFromRemote ¶ added in v0.1.4
func (conn *MySSHConn) CopyFileListFromRemote(fileListSource []string, FileDirDest string) (err error)
CopyFileListFromRemote copies given files from remote to local
func (*MySSHConn) CopyFileListFromRemoteWithNewName ¶ added in v0.1.4
func (conn *MySSHConn) CopyFileListFromRemoteWithNewName(fileListSource []string, FileListDest []string) (err error)
CopyFileListFromRemoteWithNewName copies file from remote to local, it copies file contents and rename files to given file names
func (*MySSHConn) CopyFromRemote ¶ added in v0.1.4
CopyFromRemote copies no matter a directory or a file from remote to local
func (*MySSHConn) CopySingleFileFromRemote ¶ added in v0.1.4
func (conn *MySSHConn) CopySingleFileFromRemote(fileNameSource string, fileNameDest string) (err error)
CopySingleFileFromRemote copies one single file from remote to local
func (*MySSHConn) CopySingleFileToRemote ¶ added in v0.1.4
func (conn *MySSHConn) CopySingleFileToRemote(fileNameSource string, fileNameDest string) (err error)
CopySingleFileToRemote copies one single file from local to remote
func (*MySSHConn) CopyToRemote ¶ added in v0.1.4
CopyFromRemote copies no matter a directory or a file from local to remote
func (*MySSHConn) ExecuteCommand ¶ added in v0.1.4
ExecuteCommand executes shell command on the remote host
func (*MySSHConn) GetHostName ¶ added in v0.1.4
GetHostName returns hostname of remote host
func (*MySSHConn) GetPathDirMapRemote ¶ added in v0.1.5
func (conn *MySSHConn) GetPathDirMapRemote(fileDirMap map[string]string, dirName, rootPath string) (err error)
GetPathDirMapRemote reads all subdirectories and files of given directory on the remote host and calculate the relative path of rootPath, then map the absolute path of subdirectory names and file names as keys, relative paths as values to fileDirMap
func (*MySSHConn) IsDir ¶ added in v0.1.4
IsDir returns if given path on the remote host is a directory or not
func (*MySSHConn) IsEmptyDir ¶ added in v0.1.4
IsEmptyDir returns if given directory is empty or not
func (*MySSHConn) ListPath ¶ added in v0.1.4
ListPath returns subdirectories and files of given path on the remote host, it returns a slice of sub paths
func (*MySSHConn) PathExists ¶ added in v0.1.5
PathExists returns if given path exists