command

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	internal.Shared
	Shell struct {
		Enabled bool

		CustomSh struct {
			Enabled bool
			ShName  string
			ShArg   string // Shell execution cmd
		}
		// contains filtered or unexported fields
	}
	Chroot struct {
		Route   string
		Enabled bool
	}
}

global struct

func InitCmd added in v1.3.0

func InitCmd(Command string) Cmd

Creates a Cmd structure

func InitCmdf added in v1.6.0

func InitCmdf(Command string, args ...any) Cmd

It's the same as InitCmd(fmt.Sprintf(command,args...))

func (Cmd) CombinedOut added in v1.3.0

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

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

func (*Cmd) CustomShell added in v1.3.0

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

Set a custom shell to exec the command

func (*Cmd) CustomStd added in v1.3.0

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

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

func (Cmd) GetExec added in v1.3.0

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

Returns the exec.Cmd structure with all parameters already configured

func (Cmd) Out added in v1.3.0

func (sh Cmd) 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 (*Cmd) Run added in v1.3.0

func (sh *Cmd) Run() error

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

func (*Cmd) RunWithShell added in v1.3.0

func (sh *Cmd) RunWithShell(set bool)

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

func (Cmd) SetAndCombinedOut added in v1.3.0

func (sh Cmd) 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 (Cmd) SetAndCombinedOutf added in v1.6.0

func (sh Cmd) SetAndCombinedOutf(command string, args ...any) (out string, err error)

It is the same as a SetAndCombinedOut(fmt.Sprintf(command,args)) but shortened for better handling.

func (Cmd) SetAndOut added in v1.3.0

func (sh Cmd) 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 (Cmd) SetAndOutf added in v1.6.0

func (sh Cmd) SetAndOutf(command string, args ...any) (out string, err error)

Is the same as a SetAndOut(fmt.Sprintf(command,args)) but shortened for better handling

func (Cmd) SetAndRun added in v1.3.0

func (sh Cmd) 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 (Cmd) SetAndRunf added in v1.6.0

func (sh Cmd) SetAndRunf(command string, args ...any) error

Is the same as a SetAndRun(fmt.Sprintf(command,args)) but shortened for better handling

func (Cmd) SetAndStart added in v1.3.0

func (sh Cmd) 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 (Cmd) SetAndStartf added in v1.6.0

func (sh Cmd) SetAndStartf(command string, args ...any) (err error)

It is the same as a SetAndStart(fmt.Sprintf(command,args)) but shortened for better handling.

func (*Cmd) SetChroot added in v1.5.0

func (sh *Cmd) SetChroot(mountPoint string)

func (*Cmd) SetChrootf added in v1.6.0

func (sh *Cmd) SetChrootf(mountPoint string, args ...any)

func (Cmd) Start added in v1.3.0

func (sh Cmd) Start() error

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

func (*Cmd) Stderr added in v1.3.0

func (sh *Cmd) Stderr(set bool)

func (*Cmd) Stdin added in v1.3.0

func (sh *Cmd) Stdin(set bool)

func (*Cmd) Stdout added in v1.3.0

func (sh *Cmd) Stdout(set bool)

func (*Cmd) UseBashShell added in v1.3.0

func (sh *Cmd) UseBashShell(set bool)

type SudoCmd added in v1.3.0

type SudoCmd struct {
	Cmd
	// contains filtered or unexported fields
}

func Sudo_Cmd

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

Runs a command as sudo

func (SudoCmd) CombinedOut added in v1.3.0

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

func (SudoCmd) Out added in v1.3.0

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

func (SudoCmd) Run added in v1.3.0

func (sh SudoCmd) Run() error

func (*SudoCmd) SetSudoPasswd added in v1.3.0

func (sh *SudoCmd) SetSudoPasswd(password string)

Sudo parameters

func (SudoCmd) Start added in v1.3.0

func (sh SudoCmd) Start() error

Jump to

Keyboard shortcuts

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