-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_tty.go
More file actions
32 lines (26 loc) · 742 Bytes
/
cmd_tty.go
File metadata and controls
32 lines (26 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"os"
"os/exec"
"path/filepath"
"syscall"
"github.com/urfave/cli"
)
var ttyCommand = cli.Command{
Name: "tty",
Usage: "open a terminal to the virtual machine",
Description: "use screen to open a virtual terminal connected to the dlite vm, for most cases SSH is recommended but this can be useful for debugging",
Action: func(ctx *cli.Context) error {
currentUser := getUser()
ttyPath := filepath.Join(getPath(currentUser), "vm.tty")
bin, err := exec.LookPath("screen")
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
err = syscall.Exec(bin, []string{"screen", ttyPath}, os.Environ())
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
},
}