MCPcopy Create free account
hub / github.com/DBCDK/morph / CmdInteractive

Method CmdInteractive

ssh/ssh.go:194–214  ·  view source on GitHub ↗
(host Host, timeout int, parts ...string)

Source from the content-addressed store, hash-verified

192}
193
194func (sshCtx *SSHContext) CmdInteractive(host Host, timeout int, parts ...string) {
195 ctx, cancel := utils.ContextWithConditionalTimeout(context.TODO(), timeout)
196 defer cancel()
197
198 cmd, err := sshCtx.CmdContext(ctx, host, parts...)
199 if err == nil {
200 cmd.Stdout = os.Stderr
201 cmd.Stderr = os.Stderr
202 err = cmd.Run()
203 }
204
205 // context was cancelled
206 if ctx.Err() != nil {
207 fmt.Fprintf(os.Stderr, "Exec of cmd: %s timed out\n", parts)
208 return
209 }
210
211 if err != nil {
212 fmt.Fprintf(os.Stderr, "Exec of cmd: %s failed with err: '%s'\n", parts, err.Error())
213 }
214}
215
216func askForSudoPassword() (string, error) {
217 fmt.Fprint(os.Stderr, "Please enter remote sudo password: ")

Callers

nothing calls this directly

Calls 4

CmdContextMethod · 0.95
ErrorMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected