interface-if.html

来自「Intercom 是一个 Unix系统上灵活的语音传输软件。支持标准音频压缩比如」· HTML 代码 · 共 236 行

HTML
236
字号
<HTML><HEAD><TITLE>Conditionals</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.77+"><LINKREL="HOME"TITLE="Intercom"HREF="intercom.html"><LINKREL="UP"TITLE="Interfacing With Intercom"HREF="interface.html"><LINKREL="PREVIOUS"TITLE="Executing external programs"HREF="interface-exec.html"><LINKREL="NEXT"TITLE="Putting it all Together"HREF="interface-final.html"></HEAD><BODYCLASS="SECTION"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Intercom: Version 0.15 Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="interface-exec.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 5. Interfacing With Intercom</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="interface-final.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECTION"><H1CLASS="SECTION"><ANAME="INTERFACE-IF"></A>Conditionals</H1><P>Intercom can execute commands conditionally based on the exit-code ofa shell command.  This is done with the <BCLASS="COMMAND">if</B> command.  Itborrows much of its syntax from shell though it is much more limited.  Thesyntax of <BCLASS="COMMAND">if</B> is as follows.</P><P>if &#60;<TTCLASS="REPLACEABLE"><I>shell-command</I></TT>&#62;&#60;<TTCLASS="REPLACEABLE"><I>intercom-command</I></TT>&#62;[else &#60;<TTCLASS="REPLACEABLE"><I>else-command</I></TT>&#62;]</P><P>The <BCLASS="COMMAND">if</B> command will execute<TTCLASS="REPLACEABLE"><I>&#60;intercom-command&#62;</I></TT>if the exit status of <TTCLASS="REPLACEABLE"><I>&#60;shell-command&#62;</I></TT> is 0;otherwise, <TTCLASS="REPLACEABLE"><I>&#60;else-command&#62;</I></TT> is executed. <DIVCLASS="NOTE"><P></P><TABLECLASS="NOTE"WIDTH="100%"BORDER="0"><TR><TDWIDTH="25"ALIGN="CENTER"VALIGN="TOP"><IMGSRC="/usr/share/sgml/docbook/stylesheet/dsssl/modular/images/note.gif"HSPACE="5"ALT="Note"></TD><TDALIGN="LEFT"VALIGN="TOP"><P>The else clause in an if command can beomitted.</P></TD></TR></TABLE></DIV></P><P>If can further be extended to check for a specific exit-code usingoperators such as =, &#60;, and &#62;.  These will test the exit-code againstthe value specified.  The valid operators are = (equal to), != (not equal),&#60; (less than), &#62; (greater than), &#60;= (less than or equal to), and &#62;=(greater or equal to).  For example, to execute the hangup command if theexit-code of testprog.sh was greater than 1, you would enter thefollowing.</P><P><TTCLASS="PROMPT">intercom: </TT><BCLASS="COMMAND">If testprog.sh '&#62;' 1 hangup</B></P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="interface-exec.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="intercom.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="interface-final.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Executing external programs</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="interface.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Putting it all Together</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?