On this page:
remote?
remote
ssh
scp
at-remote
make-sure-remote-is-ready
remote-host
current-ssh-verbose

1 Remote Shells🔗ℹ

 (require remote-shell/ssh) package: remote-shell-lib

procedure

(remote? v)  boolean?

  v : any/c
Returns #t if v is a remote-host representation produced by remote, #f otherwise.

procedure

(remote #:host host    
  [#:kind kind    
  #:user user    
  #:shell shell    
  #:env env    
  #:remote-tunnels remote-tunnels    
  #:key key    
  #:timeout timeout-secs])  remote?
  host : string?
  kind : (or/c 'ip 'docker) = 'ip
  user : string? = ""
  shell : (listof string?) = '("/bin/sh" "-c")
  env : (listof (cons/c string? string?)) = '()
  remote-tunnels : 
(listof (cons/c (integer-in 1 65535)
                (integer-in 1 65535)))
 = null
  key : (or/c #f path-string?) = #f
  timeout-secs : real? = 600
Creates a representation of a remote host. The host argument specifies the host for an ssh connection or a Docker container name, depending on whether kind is 'ip or 'docker. The user argument is only used for 'ip hosts; if user is empty, then the current user name is used for the remote host.

The shell argument specifies the command and arguments that are used to prefix a shell string to execute it on the remote host via ssh.

The env argument specifies environment variables to set before running any command on the remote host.

The remote-tunnels argument specifies ports to tunnel from the remote host back to the local host; it must be '() for a 'docker host. The first port number in each pair is the port number on the remote host, and the second port number is the port that it tunnels to on the local host.

If key is not #f, then it is used as the path to an identity file used for public-key authentication for a 'ip host/

The timeout argument specifies a timeout after which a remote command will be considered failed.

Changed in version 1.3 of package remote-shell-lib: Added support for Docker containers, the kind argument, and the shell argument.

procedure

(ssh remote 
  command ... 
  [#:mode mode 
  #:failure-log failure-dest 
  #:success-log success-dest 
  #:show-time? show-time?]) 
  (or/c void? boolean? (cons/c boolean? bytes?))
  remote : remote?
  command : any/c
  mode : (or/c 'error 'result 'output) = 'error
  failure-dest : (or/c #f path-string?) = #f
  success-dest : (or/c #f path-string?) = #f
  show-time? : any/c = #f
Runs a shell command at remote, were the commands are converted to a string via display and concatenated (with no additional spaces) to specify the remote shell command.

The implementation of the remote command depends on remote:
  • If remote’s kind is 'ip and its host is "localhost", then remote’s shell command is used directly.

  • Otherwise, if remote’s kind is 'ip, then the remote command is run by ssh as found by find-system-path.

  • If remote’s kind is 'docker, then the remote command is run by docker exec using docker as found by find-system-path. The Docker container named by remote must be started already.

If mode is 'error, then the result is (void) or an exception is raised if the remote command fails with an connection error, an error exit code, or by timing out. If mode is 'result, then the result is #t for success or #f for failure. If mode is 'output, then the result is a pair containing whether the command succeeded and a byte string for the command’s output (including error output).

If failure-dest is not #f, then if the command fails, the remote output (including error output) is recorded to the specified file. If success-dest is not #f, then if the command fails, the remote output (including error output) is recorded to the specified file.

procedure

(scp remote source dest [#:mode mode])  (or/c void? boolean?)

  remote : remote?
  source : path-string?
  dest : path-string?
  mode : (or/c 'error 'result 'output) = 'error
Copies a file to/from a remote host. Use at-remote to form either the source or dest argument.

The remote copy is implemented with scp as found by find-system-path if remote’s kind is 'ip, and it is implemented with docker cp using docker as found by find-system-path if remote’s kind is 'docker.

If mode is 'error, then the result is (void) or an exception is raised if the remote command fails. If mode is 'result, then the result is #t for success or #f for failure.

procedure

(at-remote remote path)  string?

  remote : remote?
  path : path-string?
Combines remote and path to form an argument for scp to specify a path at the remote host.

procedure

(make-sure-remote-is-ready remote    
  [#:tries tries])  void?
  remote : remote?
  tries : exact-nonnegative-integer? = 3
Runs a simple command at remote to check that it receives connections, trying up to tries times.

procedure

(remote-host remote)  string?

  remote : remote?
Gets the hostname that the remote is set to use in string form.

Added in version 1.2 of package remote-shell-lib.

parameter

(current-ssh-verbose)  boolean?

(current-ssh-verbose on?)  void?
  on? : any/c
A parameter that determines whether ssh echos its command to (currrent-output-port).

Added in version 1.3 of package remote-shell-lib.