[Freeswitch-users] Problem Verifying an existing file with lua

Sammy Govind govoiper at gmail.com
Sun Nov 6 18:00:49 MSK 2011


Hey,
What I understand you are trying to do is get a variable name from FS and
check from LUA if the file exists ! file_name_ok is just a flag to return
true or false depending upon existence of caal_screen_filename..if this is
the case then

datei = session:getVariable("file_**name_ok");  --You are getting the
variable containing filename here.
shouldn't it be ?
datei = session:getVariable("call_screen_filename");

also,

if (file_exists(datei..extension.**.".wav")) then
> session:setVariable("file_**name_ok", "true");
> else
> session:setVariable("file_**name_ok", "true");
> end

returns true in any case file exists or not.

Please see if this is right !

--
Regards,
Sammy

On Sun, Nov 6, 2011 at 4:55 PM, Thomas Hoellriegel <admin at blindi.net> wrote:

> Hi all,
> I like to export a vatiable to my dialplan.
>  The variable file_name_ok should give back the value true if the file
> exists
> My fialplan:
> <action application="lua" data="file.lua ${call_screen_filename}"/>
>  <action application="log" data="the value: ${file_name_ok}"/>
>
> My problem: i can.t export the variable from the luascript
>
> my scipt:
> -- function used to check for the existence of a file
> function file_exists(fname)
> local f = io.open(fname, "r")
> if (f and f:read()) then return true end
> end
> if ( session:ready() ) then
> session:answer( );
>
> datei = session:getVariable("file_**name_ok");
> if (file_exists(datei..extension.**.".wav")) then
> session:setVariable("file_**name_ok", "true");
> else
> session:setVariable("file_**name_ok", "true");
> end
> end
>
> can your help me please?
>
>
>
> ---------------
> Du kannst mich jederzeit kostenlos per Festnetz erreichen unter:
> http://www.blindi.net/callback
> homepage: http://www.blindi.net
> blinde-misc mailingliste für blinde. anmeldung unter:
> http://www.blindi.net/mailman/**listinfo/blinde-misc<http://www.blindi.net/mailman/listinfo/blinde-misc>
>
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20111106/cc312d1d/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list