check for linux command

This commit is contained in:
谢桂纲 2024-01-26 10:10:34 +08:00
parent af7f8995df
commit 5786bfe6ea
13 changed files with 295 additions and 1 deletions

9
@export/centos.d.ts vendored
View File

@ -9,6 +9,15 @@
* > this module only works on linux system
*/
declare namespace centos {
/**
* check command is existsed on linux system or not?
*
*
* @param command -
* @param env
* + default value Is ``null``.
*/
function check_command_exists(command: string, env?: object): boolean;
/**
* @param x default value Is ``'-tulnp'``.
* @param verbose default value Is ``false``.

6
@export/index.d.ts vendored
View File

@ -10,5 +10,11 @@ declare namespace Darwinism {
}
/**
*/
function ___check_netstat(): object;
/**
*/
function ___config_runtime_env(): object;
/**
*/
function no_netstat_warning(): object;
}

20
R/env.R
View File

@ -11,5 +11,23 @@ const ___config_runtime_env = function() {
#' @details this function only works for linux platform
#'
const ___check_netstat = function() {
if ((Sys.info()[['sysname']]) != "Win32NT") {
if (!centos::check_command_exists("netstat")) {
no_netstat_warning();
}
}
}
#' show warning message about missing ``netstat`` command
#'
const no_netstat_warning = function() {
let message = [
"warning: no `netstat` command could be found on your linux system, ipc parallel may be run into a network error!",
"please consider install the command at first and then run the computing task again: sudo yum install net-tools"
];
print(message);
warning(message);
invisible(NULL);
}

View File

@ -1,3 +1,4 @@
const .onLoad = function() {
___config_runtime_env();
___check_netstat();
}

View File

@ -3,4 +3,5 @@
> this module only works on linux system
+ [check_command_exists](centos/check_command_exists.1) check command is existsed on linux system or not?
+ [netstat](centos/netstat.1)

View File

@ -0,0 +1,21 @@
.\" man page create by R# package system.
.TH CENTOS 1 2000-Jan "check_command_exists" "check_command_exists"
.SH NAME
check_command_exists \- check command is existsed on linux system or not?
.SH SYNOPSIS
\fIcheck_command_exists(\fBcommand\fR as string,
[\fB<Environment>\fR]);\fR
.SH DESCRIPTION
.PP
check command is existsed on linux system or not?
.PP
.SH OPTIONS
.PP
\fBcommand\fB \fR\- -.
.PP
.SH SEE ALSO
centos
.SH FILES
.PP
Darwinism.dll
.PP

15
man/___check_netstat.1 Normal file
View File

@ -0,0 +1,15 @@
.TH ___CHECK_NETSTAT 1 2024-Jan "" "Check of netstat tool is installed or not"
.SH NAME
___check_netstat \- ___check_netstat()
.SH SYNOPSIS
\fI___check_netstat()\fR
.SH DETAILS
.PP
this function only works for linux platform
.PP
.SH FILES
.PP
SMRUCC/R#.declare_function.___check_netstat at env.R:line 13
.PP
.SH COPYRIGHT
Copyright © xieguigang, MIT Licensed 2024

11
man/no_netstat_warning.1 Normal file
View File

@ -0,0 +1,11 @@
.TH NO_NETSTAT_WARNING 1 2024-Jan "" "show warning message about missing ``netstat`` command"
.SH NAME
no_netstat_warning \- no_netstat_warning()
.SH SYNOPSIS
\fIno_netstat_warning()\fR
.SH FILES
.PP
SMRUCC/R#.declare_function.no_netstat_warning at env.R:line 23
.PP
.SH COPYRIGHT
Copyright © xieguigang, MIT Licensed 2024

View File

@ -87,6 +87,12 @@ table caption {font-size:14px;font-weight:bolder;}
<table class="table-three-line">
<caption>.NET clr function exports</caption>
<tbody><tr>
<td id="check_command_exists">
<a href="./centos/check_command_exists.html">check_command_exists</a>
</td>
<td><p>check command is existsed on linux system or not?</p></td>
</tr>
<tr>
<td id="netstat">
<a href="./centos/netstat.html">netstat</a>
</td>

View File

@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<title>check command is existsed on linux system or not?</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="../../_assets/page.css">
</head>
<body>
<div class="container">
<table style="width: 100%;">
<tr>
<td>check_command_exists {centos}</td>
<td style="text-align: right;">R Documentation</td>
</tr>
</table>
<h2>check command is existsed on linux system or not?</h2>
<h3>Description</h3>
<h3>Usage</h3>
<div style="width: 100%; padding-left: 3%; color: black;">
<pre><code class='language-R' style="color: black; font-weight:normal;"><strong>check_command_exists</strong>(<i>command</i>);</code></pre>
</div>
<h3>Arguments</h3>
<table>
<dt>command</dt>
<dd><p><p>-</p></p></dd>
</table>
<h3 style="display: none;">Details</h3>
<h3 style="display: block">Authors</h3>
Darwinism
<h3>Value</h3>
this function returns data object of type boolean.<h4>clr value class</h4><ul><li>boolean</li></ul>
<h3 style="display: none;">Examples</h3>
<hr />
<div style="text-align: center;">[Package <em>centos</em> version 1.0.0.0 <a
href="../centos.html">Index</a>]
</div>
</div>
</body>
<script type="text/javascript" src="../../_assets/R_syntax.js"></script>
<script type="text/javascript" src="../../_assets/highlights.js"></script>
<script type="text/javascript">r_highlights("example_r");</script>
</html>

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title><p>Check of netstat tool is installed or not</p></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="../../_assets/page.css">
</head>
<body>
<div class="container">
<table style="width: 100%;">
<tr>
<td>___check_netstat {Darwinism}</td>
<td style="text-align: right;">R Documentation</td>
</tr>
</table>
<h2><p>Check of netstat tool is installed or not</p></h2>
<h3>Description</h3>
<h3>Usage</h3>
<div style="width: 100%; padding-left: 3%; color: black;">
<pre><code class='language-R' style="color: black; font-weight:normal;"><strong>___check_netstat</strong>();</code></pre>
</div>
<h3>Arguments</h3>
<table>
</table>
<h3 style="display: block;">Details</h3>
<p>this function only works for linux platform</p>
<h3 style="display: block">Authors</h3>
xieguigang
<h3>Value</h3>
This function has no value returns.
<h3 style="display: none;">Examples</h3>
<hr />
<div style="text-align: center;">[Package <em>Darwinism</em> version 1.0.0.1254 <a
href="../Darwinism.html">Index</a>]
</div>
</div>
</body>
<script type="text/javascript" src="../../_assets/R_syntax.js"></script>
<script type="text/javascript" src="../../_assets/highlights.js"></script>
<script type="text/javascript">r_highlights("example_r");</script>
</html>

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title><p>show warning message about missing <code>netstat</code> command</p></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="../../_assets/page.css">
</head>
<body>
<div class="container">
<table style="width: 100%;">
<tr>
<td>no_netstat_warning {Darwinism}</td>
<td style="text-align: right;">R Documentation</td>
</tr>
</table>
<h2><p>show warning message about missing <code>netstat</code> command</p></h2>
<h3>Description</h3>
<h3>Usage</h3>
<div style="width: 100%; padding-left: 3%; color: black;">
<pre><code class='language-R' style="color: black; font-weight:normal;"><strong>no_netstat_warning</strong>();</code></pre>
</div>
<h3>Arguments</h3>
<table>
</table>
<h3 style="display: none;">Details</h3>
<h3 style="display: block">Authors</h3>
xieguigang
<h3>Value</h3>
This function has no value returns.
<h3 style="display: none;">Examples</h3>
<hr />
<div style="text-align: center;">[Package <em>Darwinism</em> version 1.0.0.1254 <a
href="../Darwinism.html">Index</a>]
</div>
</div>
</body>
<script type="text/javascript" src="../../_assets/R_syntax.js"></script>
<script type="text/javascript" src="../../_assets/highlights.js"></script>
<script type="text/javascript">r_highlights("example_r");</script>
</html>

View File

@ -14,6 +14,8 @@ RoxygenNote: 7.1.1
<h2>R Package Symbols</h2>
<ul>
<li><a href="./R/docs/___config_runtime_env.html">___config_runtime_env</a></li>
<li><a href="./R/docs/___check_netstat.html">___check_netstat</a></li>
<li><a href="./R/docs/no_netstat_warning.html">no_netstat_warning</a></li>
<li><a href="./R/docs/.onLoad.html">.onLoad</a></li>
</ul>
<h2>Library: Darwinism.dll</h2>