command

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UnixCmd

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

global struct

func Cmd

func Cmd(Command string) UnixCmd

Runs a normal command (without sudo)

func (UnixCmd) CombinedOut

func (sh UnixCmd) CombinedOut() (string, error)

It is the same as run, but returns one more string value (the output of the command)

func (*UnixCmd) CustomShell

func (sh *UnixCmd) CustomShell(Shell_Name, Exec_Arg string)

Set a custom shell to exec the command

func (*UnixCmd) CustomStd

func (sh *UnixCmd) CustomStd(Stdin, Stdout, Stderr bool)

Set a custom stdin,stdout or stderr. Default std is all in false

func (UnixCmd) GetExec

func (sh UnixCmd) GetExec() *exec.Cmd

Returns the exec.Cmd structure with all parameters already configured

func (UnixCmd) Out

func (sh UnixCmd) Out() (string, error)

It is the same as run, but skips the Std setting and returns an error value and the output as a string, i.e. exec.Command(<command>).Output()

func (*UnixCmd) Run

func (sh *UnixCmd) Run() error

Executes normally the command with the parameters set, with the classic exec.Command(<command>).Run()

func (*UnixCmd) RunWithShell

func (sh *UnixCmd) RunWithShell(set bool)

If the value is true use exec.Command([shell],[arg],input) instead of exec.Command(input[0],input[1:]...)

func (UnixCmd) SetAndCombinedOut

func (sh UnixCmd) SetAndCombinedOut(command string) (string, error)

It is the same as cmd := command.Cmd("<command>"); cmd.CombinedOut() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (UnixCmd) SetAndOut

func (sh UnixCmd) SetAndOut(command string) (string, error)

It is the same as cmd := command.Cmd("<command>"); cmd.Out() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (UnixCmd) SetAndRun

func (sh UnixCmd) SetAndRun(command string) error

It is the same as cmd := command.Cmd("<command>"); cmd.Run() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (UnixCmd) SetAndStart

func (sh UnixCmd) SetAndStart(command string) error

It is the same as cmd := command.Cmd("<command>"); cmd.Start() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (*UnixCmd) SetInput

func (sh *UnixCmd) SetInput(input string)

General parameter funcions

func (*UnixCmd) SetPath

func (sh *UnixCmd) SetPath(path string)

func (UnixCmd) Start

func (sh UnixCmd) Start() error

Run the command in a new goroutine, just like cmd.Run(), but using exec.Command(<cmd>).Start()

func (*UnixCmd) Stderr

func (sh *UnixCmd) Stderr(set bool)

func (*UnixCmd) Stdin

func (sh *UnixCmd) Stdin(set bool)

func (*UnixCmd) Stdout

func (sh *UnixCmd) Stdout(set bool)

func (*UnixCmd) UseBashShell

func (sh *UnixCmd) UseBashShell(set bool)

type UnixSudoCmd

type UnixSudoCmd struct {
	UnixCmd
	// contains filtered or unexported fields
}

func Sudo_Cmd

func Sudo_Cmd(command string, optional_password ...string) UnixSudoCmd

Runs a command as sudo

func (UnixSudoCmd) CombinedOut

func (sh UnixSudoCmd) CombinedOut() (string, error)

func (UnixSudoCmd) Out

func (sh UnixSudoCmd) Out() (string, error)

func (UnixSudoCmd) Run

func (sh UnixSudoCmd) Run() error

func (*UnixSudoCmd) SetSudoPasswd

func (sh *UnixSudoCmd) SetSudoPasswd(password string)

Sudo parameters

func (UnixSudoCmd) Start

func (sh UnixSudoCmd) Start() error

Jump to

Keyboard shortcuts

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