command

package module
v0.0.0-...-81872a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 14 Imported by: 0

README

go-command

Documentation

Index

Constants

View Source
const (
	CertPassword sshMode = iota
	CertPublicKeyFile

	DefaultTimeout = 60
)

Variables

This section is empty.

Functions

func Copy

func Copy(size int64, mode os.FileMode, fileName string, contents io.Reader, destinationPath string, session *ssh.Session) error

func CopyPath

func CopyPath(filePath string, destinationPath string, session *ssh.Session) error

Types

type BaseCommand

type BaseCommand interface {
	RunCommand(cmd string) (string, error)
	RunCommands(cmds ...string) ([]string, error)
	RunShell(filePath string, remotePath string, params ...string) (outputs []string, err error)
	SendFile(localPath string, remotePath string) error
	SendDir(localDir, remoteDir string) error
}

type Command

type Command interface {
	BaseCommand
	GetURL() string
	GetIP() string
	RunTransaction(do func(tx BaseCommand) error) error
}

type Local

type Local struct {
	// contains filtered or unexported fields
}

func NewLocal

func NewLocal() *Local

func (*Local) GetIP

func (me *Local) GetIP() string

func (*Local) GetURL

func (me *Local) GetURL() string

func (*Local) RunCommand

func (me *Local) RunCommand(cmd string) (string, error)

func (*Local) RunCommands

func (me *Local) RunCommands(cmds ...string) ([]string, error)

func (*Local) RunShell

func (me *Local) RunShell(filePath string, remotePath string, params ...string) (outputs []string, err error)

不实现

func (*Local) RunTransaction

func (me *Local) RunTransaction(do func(tx BaseCommand) error) error

不实现

func (*Local) SendDir

func (me *Local) SendDir(localDir, remoteDir string) error

不实现

func (*Local) SendFile

func (me *Local) SendFile(localPath string, remotePath string) error

发送单个文件 注意路径必须带文件名

type Path

type Path struct {
	Path  string
	IsDir bool
}

type SSHClient

type SSHClient struct {
	IP   string
	User string
	Cert string
	Port int
	Mode sshMode
}

func NewSSHClientWithPassword

func NewSSHClientWithPassword(ip string, user string, password string) *SSHClient

func (*SSHClient) GetIP

func (me *SSHClient) GetIP() string

func (*SSHClient) GetURL

func (me *SSHClient) GetURL() string

func (*SSHClient) RunCommand

func (me *SSHClient) RunCommand(cmd string) (string, error)

func (*SSHClient) RunCommands

func (me *SSHClient) RunCommands(cmds ...string) ([]string, error)

func (*SSHClient) RunShell

func (me *SSHClient) RunShell(filePath string, remotePath string, params ...string) (outputs []string, err error)

func (*SSHClient) RunTransaction

func (me *SSHClient) RunTransaction(do func(ctx TransactionContext) error) error

func (*SSHClient) SendDir

func (me *SSHClient) SendDir(localDir string, remoteDir string) error

发送整个目录 注意 远程目录需要自己指定,函数不回将原目录发送,路径必须带 '/' 例如 ../scrpt, ./不会在远程目录生成script目录

func (*SSHClient) SendFile

func (me *SSHClient) SendFile(localPath string, remotePath string) error

发送单个文件 注意路径必须带文件名

type TransactionContext

type TransactionContext struct {
	// contains filtered or unexported fields
}

func (*TransactionContext) RunCommand

func (me *TransactionContext) RunCommand(cmd string) (string, error)

func (*TransactionContext) RunCommands

func (me *TransactionContext) RunCommands(cmds ...string) ([]string, error)

func (*TransactionContext) RunShell

func (me *TransactionContext) RunShell(filePath string, remotePath string, params ...string) (outputs []string, err error)

func (*TransactionContext) SendDir

func (me *TransactionContext) SendDir(localDir, remoteDir string) error

func (*TransactionContext) SendFile

func (me *TransactionContext) SendFile(localPath string, remotePath string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL