Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > d56e2615a43e036877e0b6cfab8e0892 > files > 302

fldigi-doc-3.20-3.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"><title>Exec Macro</title></head><body style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 204);" alink="#000099" link="#000099" vlink="#990099"><h1 style="text-align: center;">Exec Macro</h1><p>The
&lt;EXEC&gt; ... &lt;/EXEC&gt; macro is designed to be used on the
Linux OS as it supports fully functional pipes. &nbsp;Windows' version
of file pipes is not fully POSIX compliant, but the function might work
in the environment. &nbsp;Consider all that the following allows you to
do from within fldigi and you might want to consider changing over to
Linux.</p>The &lt;EXEC&gt; macro defines an external child process (or
processes) that will be called by fldigi when the macro key is invoked.
&nbsp;<br><h3>Exported variables</h3>Fldigi exports a set of variables to the child process and
adds ~/.fldigi/scripts to the PATH variable before running the shell
code. &nbsp; This is the directory location for all executable scripts
and programs which you might want to call from within the macro.
&nbsp;Some examples will be given later. &nbsp;Open the macro editor
for an undefined macro key and enter the following: <br><ul><li><exec>&lt;EXEC&gt;env | grep FLDIGI&lt;/EXEC&gt;</exec></li></ul>Save
the macro; call it ENV. &nbsp;Then press the newly defined macro key.
&nbsp;All of the exported variables will be shown in the transmit
window.<br>Here is an example of the results:<br><br><div style="margin-left: 40px;">FLDIGI_RX_IPC_KEY=9876<br>FLDIGI_LOG_LOCATOR=FM02BT<br>FLDIGI_TX_IPC_KEY=6789<br>FLDIGI_LOG_RST_IN=<br>FLDIGI_LOG_FREQUENCY=3581.000<br>FLDIGI_AZ=108<br>FLDIGI_MY_CALL=W1HKJ<br>FLDIGI_LOG_TIME=2113<br>FLDIGI_MY_NAME=Dave<br>FLDIGI_VERSION=3.0preG<br>FLDIGI_LOG_NOTES=<br>FLDIGI_LOG_QTH=Mt Pleasant, SC<br>FLDIGI_MY_LOCATOR=EM64qv<br>FLDIGI_DIAL_FREQUENCY=3580000<br>FLDIGI_CONFIG_DIR=/home/dave/.fldigi/<br>FLDIGI_LOG_RST_OUT=<br>FLDIGI_MODEM=BPSK31<br>FLDIGI_LOG_CALL=KH6TY<br>FLDIGI_MODEM_LONG_NAME=BPSK-31<br>FLDIGI_AUDIO_FREQUENCY=1000<br>FLDIGI_LOG_NAME=Skip<br>FLDIGI_PID=14600<br>FLDIGI_FREQUENCY=3581000<br></div><br>All of the above envelope variables can be referenced in a shell script that is called from within fldigi.<br><h3>Detection of existing scripts</h3>In anticipation of a collection of useful "fldigi scripts", the
macro browser contains a<exec></exec> macro line for each
executable file&nbsp;found in the scripts directory. <p>The EXEC macro allows the text that is read from the child process to be
parsed for more fldigi macros. For example, try this macro:<br><br>

&lt;EXEC&gt;cat foo&lt;/EXEC&gt;<br><br>

where foo is a file that contains:<br><br>

&lt;MYCALL&gt;<br><br>

This may have some interesting uses but, if it is undesirable, it can be
suppressed with an extra layer of redirection.  Instead of
&lt;EXEC&gt;command&lt;/EXEC&gt;, you would use &lt;EXEC&gt;noexp command&lt;/EXEC&gt; where noexp is
the following very simple script:&nbsp;</p>

<p>snip---------------------------------------<br>
#!/bin/bash<br><br>
echo -n "&lt;STOP&gt;"<br>
"$@" &nbsp; &nbsp; # run the command<br>
r=$? &nbsp; &nbsp; # save its exit code<br>
echo -n "&lt;CONT&gt;"<br>
exit $?<br>
snip---------------------------------------</p>

<p>There are three additional MACRO definitions that expand the capability of
the &lt;EXEC&gt; command: &lt;STOP&gt;, &lt;CONT&gt; and &lt;GET&gt;.</p>
<p>The &lt;STOP&gt; and &lt;CONT&gt; macros stop and resume the expansion of all
&lt;MACRO&gt; strings. For example, &lt;STOP&gt;&lt;MYCALL&gt;&lt;CONT&gt;&lt;MYCALL&gt;&nbsp;
would only expand the second &lt;MYCALL&gt;.

By wrapping the command output in this way we can be sure that
no text will be expanded. You might even use

<br><br>"$@" | sed "s/&lt;CONT&gt;//g"

<br><br>if you feel paranoid.&nbsp;</p>
<p>You can "fork and forget" with an exec macro defined as:&nbsp;&lt;EXEC&gt;exec command -args &gt;/dev/null&lt;/EXEC&gt;</p>
<p>Any of the text that appears between the &lt;EXEC&gt; and &lt;/EXEC&gt; can
reference an executable program or shell command found in the
~/.fldigi/scripts directory.</p>
<p>Any text output that is returned by the program or script program (or the
result of the in-line command) is always returned to the transmit
buffer and appears as appended to the transmit window.

</p><h3>Querying an external database</h3>
<p>The &lt;GET&gt; command captures&nbsp;returned text from the external process and parses it for the following content:</p>
<p>$NAMEtext_name$QTHtext_qth</p>
<p>If either $NAME or $QTH is present the trailing text is transferred to the
LOG_NAME or LOG_QTH widgets respectively. &nbsp;This means that you can create a
script that accesses a local or net based database of callsign data and
parse that data to form the above console output. &nbsp;Fldigi will
accept that output, parse it and populate the associated&nbsp;log entries.
&nbsp;Cool! &nbsp;Now for some examples. &nbsp;Here is a perl script that
performs the above for the University of Arkansas on-line callsign
database, <a href="ualr-telnet.html">ualr-telnet</a>.</p>
<p>The matching macro key definition for the above is:</p>
<p>&lt;EXEC&gt;ualr-telnet.pl $FLDIGI_LOG_CALL&lt;/EXEC&gt;&lt;GET&gt;</p>
<p>which I named "ualr ?"</p><h3>Google Earth Map</h3>Here is a really cool perl script, <a href="map.html">Google Earth Mapping</a>,
that accepts the current "Loc" field in the logging area and generates
a Google Earth map which is displayed in your default browser.
&nbsp;The macro call is &lt;EXEC&gt;map.pl&lt;/EXEC&gt;<span style="text-decoration: underline;"></span>

<h3>Custom dates/times</h3>
<p>You can use &lt;EXEC&gt; to create custom date/time entries. For
example, BARTG contesters use %H%M, but in other circumstances a user
might prefer %H:%M or %H.%M etc.</p>
<p>Create the following script file in the ~/.fldigi/scripts directory, call it mytime:</p>
<p>snip---------------------------------------
<br><br>#!/bin/sh<br>date --utc "+%H:%M"<br>
<br>snip---------------------------------------
<br><br>date calls strftime, the same C function used by fldigi for the ZDT/LDT
expansion, so it has an equally vast number of format strings to choose
from. Look for them in its manual page.</p>
<p>Give "mytime" execute permissions with a file manager or with chmod:
   chmod u+x ~/.fldigi/scripts/mytime.</p>
<p>Test it on the command line and make sure it works correctly:
   ~/.fldigi/scripts/mytime</p><p>Restart
fldigi. The mytime script will now appear at the end of the list in the
macro browser, and can be entered with the &lt;&lt; button as usual.
Test that macro and you will see that &lt;EXEC&gt;mytime&lt;/EXEC&gt;
inserts the datetime in the specified format. &nbsp;</p>
<p>Of course you could have entered:<br><br>&lt;EXEC&gt;date --utc "+%H:%M"&lt;/EXEC&gt;<br><br>in the macro body text directly </p>
<p>Many&nbsp;other uses for the &lt;EXEC&gt;...&lt;/EXEC&gt; macro pair
can be imagined
when used the with ENV parameters. &nbsp;For example you could send
Azimuth data to
an automated antenna rotor. &nbsp;The exported variables should be
sufficient for a script writer to create custom loggers and clients.</p><p style="text-align: center;"><a style="font-weight: bold;" href="index.html">Contents</a></p><p style="text-align: center;"></p>
</body></html>