Dear Freeswitch users, I am developing some javascript applications that run within Freeswitch. I can read without difficulty from files located on the same machine as Freeswitch, but I can't write or create new files. The following code issues an error when trying to open a file in "write mode". var fd = new File("test.txt"); fd.open("write"); fd.write("Hello\n"); fd.close(); The error I got is: 2011-02-18 11:07:25.893733 [ERR] test.js:7 Error: File operation open failed I thought it was a sort of sandbox model issue. However I could generate a file using the following system command: session.execute("system", "echo Hello > test.txt"); The same error occurs when I tried to use the javascript function: var tmp = fetchURLFile("http://myserver/test.html", "test.txt"); This creates an empty test.txt file. I tried then to run the following system command: session.execute("system", "wget -O test.txt http://myserver/test.html"); This as well creates an empty test.txt file. If I run "wget -O test.txt http://myserver/test.html" directly from the system prompt this correctly downloads and creates the test.txt file. So my questions are: what did I miss? Is there some parameter to configure that I haven't found? Thank you in advance for your help, Gilles Gerlinger PS: Freeswitch is running over Ubuntu server 10.10 -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/writing-to-file-in-javascript-... Sent from the freeswitch-users mailing list archive at Nabble.com.
Googled on this, and found this - does that solve the issue? file.open("write,create", "text"); ________________________________________ Från: freeswitch-users-bounces@lists.freeswitch.org [freeswitch-users-bounces@lists.freeswitch.org] för gigerlin [gilles.gerlinger@free.fr] Skickat: den 5 mars 2011 18:10 Till: freeswitch-users@lists.freeswitch.org Ämne: [Freeswitch-users] writing to file in javascript Dear Freeswitch users, I am developing some javascript applications that run within Freeswitch. I can read without difficulty from files located on the same machine as Freeswitch, but I can't write or create new files. The following code issues an error when trying to open a file in "write mode". var fd = new File("test.txt"); fd.open("write"); fd.write("Hello\n"); fd.close(); The error I got is: 2011-02-18 11:07:25.893733 [ERR] test.js:7 Error: File operation open failed I thought it was a sort of sandbox model issue. However I could generate a file using the following system command: session.execute("system", "echo Hello > test.txt"); The same error occurs when I tried to use the javascript function: var tmp = fetchURLFile("http://myserver/test.html", "test.txt"); This creates an empty test.txt file. I tried then to run the following system command: session.execute("system", "wget -O test.txt http://myserver/test.html"); This as well creates an empty test.txt file. If I run "wget -O test.txt http://myserver/test.html" directly from the system prompt this correctly downloads and creates the test.txt file. So my questions are: what did I miss? Is there some parameter to configure that I haven't found? Thank you in advance for your help, Gilles Gerlinger PS: Freeswitch is running over Ubuntu server 10.10 -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/writing-to-file-in-javascript-... Sent from the freeswitch-users mailing list archive at Nabble.com. _______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org !DSPAM:4d72869b32762024114202!
Thanks Peter, That works fine now! Regards, Gilles Gerlinger -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/writing-to-file-in-javascript-... Sent from the freeswitch-users mailing list archive at Nabble.com.
participants (2)
-
gigerlin
-
Peter Olsson