Module Core_extended.Sys_utils

Various system utility functions.

val get_editor : unit ‑> string option

Get the default editor (program) for this user. This functions checks the EDITOR and VISUAL environment variables and then looks into a hard coded list of editors.

val get_editor_exn : unit ‑> string
val get_pager : unit ‑> string option

Analogous to get_editor, defaulting to a list including less and more.

val page_contents : ?⁠pager:string ‑> ?⁠pager_options:string list ‑> ?⁠tmp_name:string ‑> string ‑> unit

page_contents ?pager ?tmp_name str will show str in a pager. The optional tmp_name parameter gives the temporary file prefix. The temporary file is removed after running.

val pid_alive : Core.Pid.t ‑> bool
val get_groups : string ‑> string list
val with_tmp : pre:string ‑> suf:string ‑> (string ‑> 'a) ‑> 'a

with_tmp pre suf f creates a temp file, calls f with the file name, and removes the file afterwards.

val diff : ?⁠options:string list ‑> string ‑> string ‑> string

diff s1 s2 returns diff (1) output of the two strings. Identical files returns the empty string. The default value of options is "-d -u", to provide shorter, unified diffs.

val ip_of_name : string ‑> string

ip_of_name hostname looks up the hostname and prints the IP in dotted-quad format.

val getbyname_ip : unit ‑> string

getbyname_ip () returns the IP of the current host by resolving the hostname.

val ifconfig_ips : unit ‑> Core.String.Set.t

ifconfig_ips () returns IPs of all active interfaces on the host by parsing ifconfig output. Note that this will include 127.0.0.1, assuming lo is up.

val checked_edit : ?⁠create:bool ‑> check:(string ‑> string option) ‑> string ‑> [ `Abort | `Ok ]

checked_edit ~check file

Edit a file in safe way, like vipw(8). Launches your default editor on file and uses check to check its content.

module Sexp_checked_edit : functor (S : Core.Sexpable) -> sig ... end

Edit files containing sexps.

module Cpu_use : sig ... end

A module for getting a process's CPU use.

module Lsb_release : sig ... end