<div>ZOMG I wish I was blind like Thomas, Covici, and DelphiWorld so I wouldn't have to read this thread any more!! :P </rant></div><div><br></div>What you want to do is not possible directly from the dialplan, or even from the console. There are probably several ways to address this problem. Since I like Lua I thought a simple demonstration using a small amount of Lua to get what you want would be good. Here is a generic Lua script that you can call from the command line and feed it an argument which it will in turn execute as a system call, then return the system's output:<div>
<br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">-- sys_call.lua</font></div><div><font class="Apple-style-span" face="'courier new', monospace">-- </font></div><div><font class="Apple-style-span" face="'courier new', monospace">-- simple read from pipe </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">-- Be sure to escape spaces in the argument cuz I was to lazy to parse args properly... </font></div><div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">cmd = argv[1]; </font></div><div><font class="Apple-style-span" face="'courier new', monospace">freeswitch.consoleLog("DEBUG","sys_call.lua call with arg: '" .. cmd .. "'\n"); </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font></div><div><font class="Apple-style-span" face="'courier new', monospace">f = assert (io.popen(cmd));</font></div><div><font class="Apple-style-span" face="'courier new', monospace">res_data = ''; </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">for line in f:lines() do </font></div><div><font class="Apple-style-span" face="'courier new', monospace"> res_data = res_data .. line .. "\n"; </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">end </font></div><div><font class="Apple-style-span" face="'courier new', monospace"> </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">stream:write(res_data); </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">freeswitch.consoleLog("DEBUG","sys_call.lua result: '" .. res_data .. "'\n"); </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">f:close(); </font></div><div><br></div>Now you can go to fs_cli and do things like:</div><div><font class="Apple-style-span" face="'courier new', monospace">lua sys_call.lua ls\ -l</font></div>
<div><br></div><div>Now, Thomas, in your specific case you are trying to capture input from the caller and compare that to the output from the command: date -d <date argument> +%s and you have a script that does this comparison for you. To call your shell script from the command line with my Lua script would be this:</div>
<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">lua sys_call.lua datechk.sh\ <date value argument></font></div><div><br></div><div>(Don't forget to put a backslash in front of the space character.) To do this in the dialplan you need to use the special notation that lets you execute an API call using the "set" dialplan application. Let's say the input you capture from your caller is in variable ${nr}. You can set a new channel variable that captures the output of your script:</div>
<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace"><action application="set" data="my_result=${lua sys_call.lua datechk.sh\ ${nr}}"/></font></div><div><br>
</div><div>Now you have a new channel variable ${my_result} that contains the result of the system call to your date script. From here you will need use the dialplan "transfer" or "execute_extension" in order to do something with the result. I recommend that you create a separate dialplan context and transfer the call into that context for further processing.</div>
<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace"><action application="transfer" data="${my_result} XML handle_date_test"/></font></div><div><br></div><div>
Then your new context could be something like this:</div><div><font class="Apple-style-span" face="'courier new', monospace"><context name="handle_date_test"></font></div><div><font class="Apple-style-span" face="'courier new', monospace"> <extension name="date match is good"></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> <condition field="destination_number" expression="^good\s*$"></font></div><div><font class="Apple-style-span" face="'courier new', monospace"> <action application="log" data="INFO date matches, do stuff in action tags..."/></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> <anti-action application="log" data="INFO date does not match, handle this in anti-action tags..."/></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </condtion></font></div><div><font class="Apple-style-span" face="'courier new', monospace"> </extension></font></div><div>
<font class="Apple-style-span" face="'courier new', monospace"></context></font></div><div><br></div><div>For all of this to work you will have to change your script so that if the dates match then the script will echo "good" to the console. If the dates do not match then your script will need to echo anything other than "good".</div>
<div><br></div><div>Thomas, I respect you for trying so hard to make this work with only a braille reader and in a language that is not your first. Keep up the good work. I hope this helps.</div><div><br></div><div>-MC</div>
<div><br><div class="gmail_quote">On Sat, May 14, 2011 at 5:11 AM, Thomas Hoellriegel <span dir="ltr"><<a href="mailto:admin@blindi.net">admin@blindi.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Am 14.05.11 um 01:37 schrieb Madovsky:<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think you have to escape the $ 3 times<br>
</blockquote></div>
I don.t no. $3? I like to export the variable: dateerror from the shellscript in my fs dialplan, to make a selection from condidion field.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
\\\${nir}<br>
</blockquote>
what is the syntax in the dialplan?<br>
thank you.</blockquote><div><br></div><div><br></div></div></div>