Mate.Helpers (Mate v0.1.5) View Source
This module contains helper functions that can be used to execute commands
on the local machine, or the remote machine using the configured driver ƒrom
.mate.exs
. It also have functions to copy files from or to the remote server.
These helpers are automatically imported in a custom Mate.Pipeline.Step
.
For example:
defmodule CustomHelloUser do
use Mate.Pipeline.Step
@impl true
def run(session) do
{:ok, user} = remote_cmd(session, "whoami")
IO.puts "Hello " <> user
{:ok, session}
end
end
Link to this section Summary
Functions
Safely terminate connections and raises error
Copy a file from the remote server to the local machine
Copy a file from your local machine to the remote server
Execute a command (with arguments) on the local machine
Execute a script on the local machine
Execute a command (with arguments) on the remote machine
Execute a script on the remote machine
Link to this section Functions
Specs
bail(session :: Mate.Session.t(), message :: String.t(), error :: String.t()) :: no_return()
Safely terminate connections and raises error
Specs
copy_from(session :: Mate.Session.t(), src :: String.t(), dest :: String.t()) :: {:ok, String.t()} | {:error, String.t()}
Copy a file from the remote server to the local machine
Specs
copy_to(session :: Mate.Session.t(), src :: String.t(), dest :: String.t()) :: {:ok, String.t()} | {:error, String.t()}
Copy a file from your local machine to the remote server
Specs
local_cmd( session :: Mate.Session.t(), command :: String.t(), args :: [String.t()] ) :: {:ok, String.t()} | {:error, String.t()}
Execute a command (with arguments) on the local machine
Specs
local_script(session :: Mate.Session.t(), script :: String.t()) :: {:ok, String.t()} | {:error, String.t()}
Execute a script on the local machine
Specs
remote_cmd(session :: Mate.Session.t(), cmd :: String.t(), args :: [String.t()]) :: {:ok, String.t()} | {:error, String.t()}
Execute a command (with arguments) on the remote machine
Specs
remote_script(session :: Mate.Session.t(), script :: String.t()) :: {:ok, String.t()} | {:error, String.t()}
Execute a script on the remote machine