1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
\subsection{bashevaluate}
\label{labbashevaluate}
\noindent Name: \textbf{bashevaluate}\\
\phantom{aaa}executes a shell command and returns its output as a string\\[0.2cm]
\noindent Library names:\\
\verb| sollya_obj_t sollya_lib_bashevaluate(sollya_obj_t, ...)|\\
\verb| sollya_obj_t sollya_lib_v_bashevaluate(sollya_obj_t, va_list)|\\[0.2cm]
\noindent Usage:
\begin{center}
\textbf{bashevaluate}(\emph{command}) : \textsf{string} $\rightarrow$ \textsf{string}\\
\textbf{bashevaluate}(\emph{command},\emph{input}) : (\textsf{string}, \textsf{string}) $\rightarrow$ \textsf{string}\\
\end{center}
Parameters:
\begin{itemize}
\item \emph{command} is a command to be interpreted by the shell.
\item \emph{input} is an optional character sequence to be fed to the command.
\end{itemize}
\noindent Description: \begin{itemize}
\item \textbf{bashevaluate}(\emph{command}) will execute the shell command \emph{command} in a shell.
All output on the command's standard output is collected and returned
as a character sequence.
\item If an additional argument \emph{input} is given in a call to
\textbf{bashevaluate}(\emph{command},\emph{input}), this character sequence is written to the
standard input of the command \emph{command} that gets executed.
\item All characters output by \emph{command} are included in the character
sequence to which \textbf{bashevaluate} evaluates but two exceptions. Every NULL
character ($`\backslash 0$') in the output is replaced with
`?' as \sollya is unable to handle character sequences containing that
character. Additionally, if the output ends in a newline character
($`\backslash$n'), this character is stripped off. Other
newline characters which are not at the end of the output are left as
such.
\end{itemize}
\noindent Example 1:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> bashevaluate("LANG=C date");
Mon Feb 21 12:19:56 CET 2022
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 2:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> [| bashevaluate("echo Hello") |];
[|"Hello"|]
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 3:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> a = bashevaluate("sed -e 's/a/e/g;'", "Hallo");
> a;
Hello
\end{Verbatim}
\end{minipage}\end{center}
See also: \textbf{bashexecute} (\ref{labbashexecute})
|