cmdRun

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

执行cmd命令 执行ssh命令 利用sftp传输文件 scp其实就是遍历文件,利用sftp协议

以后可扩展出scp的功能,直接传输或下载文件夹

localFile := appPath.AppDir() + "release/keluoou-v2.2.2/keluoou3"
client, err := cmdRun.NewSSH("118.195.161.65:22")
if err != nil {
    fmt.Println(err)
return
}

client.Run("ls -alx")

dstFile := "/data/keluoou"
err = client.SftpSend(localFile, dstFile)
if err != nil {
    fmt.Println(err)
return
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cmd string) (string, error)

Types

type SshClient

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

SshClient 采用ssh密钥 登录服务器

func NewSSH

func NewSSH(rootPort string) (*SshClient, error)

NewSSH ssh连接服务器 root:port

func (*SshClient) Run

func (r *SshClient) Run(command string) (string, error)

Run 执行

func (*SshClient) SftpSend

func (r *SshClient) SftpSend(localFile, remoteFile string) error

Jump to

Keyboard shortcuts

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