Dumb question about files on a server
J. Landman Gay
jacque at hyperactivesw.com
Mon Sep 19 17:43:20 EDT 2016
On 9/19/16 3:15 PM, Graham Samuel wrote:
> I have a .lc script on the server that invokes Jacque Gay’s Zygodact
> product to generate license codes, which are then passed on to the
> payment processor. This works fine. However when a code is generated,
> it would be prudent to keep it in a file which is on the server. So I
> want to add a few lines of code to the aforesaid .lc script so that
> each code goes into a text file.
That's easy, I do it with all my Zygodact server scripts. The main thing
to be aware of is that the text file needs to have read/write
permissions. I couldn't generate a file from scratch because of the
permission issues (I'm sure there's a way around this, but I didn't know
how.) So what I do is create an empty text file on the server and give
it read/write permissions (755) manually using Fetch or any other FTP
app. I put the file directly in the CGI folder, which is inaccessible to
visitors.
After that, just add this handler to your .lc script:
on log pData
put "myLog.txt" into tFile
open file tFile for append
write pData &cr & cr to file tFile
close file tFile
end log
Then in the main body of the script, collect the data you want to store
into a variable and add a "log dataVar" line.
The reason I use open/write/close instead of "put after URL" is because
opening a file for append doesn't need to read the whole thing into
memory and then write it all back out again. It seems like a better use
of resources.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list