shell

package module
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

Shell

shell package to run powershell and bash with go.

Powershell

import "github.com/secman-team/shell"

// run a command
shell.PWSLCmd(`Write-Host "secman is 🔒"`)

// run a script
shell.PWSLCmd(`
  $x = git config user.name
  
  Write-Host $x
`)

// run a command with out
err, out, errout := shell.PWSLOut(`[System.Environment]::SetEnvironmentVariable("Path", $Env:Path + ";$SECMAN_PATH\bin", [System.EnvironmentVariableTarget]::User)`)

if err != nil {
  log.Printf("error: %v\n", err)
  fmt.Print(errout)
}

fmt.Print(out)

Bash/Shell

import "github.com/secman-team/shell"

// run a command
shell.ShellCmd(`echo "secman is 🔒"`)

// run a script
shell.ShellCmd(`
  mood="👨‍💻"

  if [ $mood != "😪" ]; then
    echo "still coding"
  fi
`)

// run a command with out
err, out, errout := shell.ShellOut(`curl --silent "https://api.github.com/repos/secman-team/secman/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'`)

if err != nil {
  log.Printf("error: %v\n", err)
  fmt.Print(errout)
}

fmt.Print(out)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PWSLCmd added in v0.3.0

func PWSLCmd(command string)

func PWSLOut added in v0.3.0

func PWSLOut(command string) (error, string, string)

func SHCore

func SHCore(cmd string, winCmd string)

func SHCoreOut added in v0.3.11

func SHCoreOut(unixCmd string, winCmd string) (error, string, string)

func ShellCmd

func ShellCmd(command string)

func ShellOut

func ShellOut(command string) (error, string, string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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