Dumb question about files on a server

Mike Bonner bonnmike at gmail.com
Mon Sep 19 11:53:53 EDT 2016


It sounds like you have an app that you want to use to manipulate files and
folders on a remote server. You could set up a script on the server as a
middle man pretty easily I think..

Something like this.. (off the top of my head)

Have it accept $_POST data, one item of which could be cmd=folder_exists,
and pass in the folder name to check..

switch $_POST["cmd"]
case "folder_exists"
    if there is not a folder $_POST["folder_name"] then
        create folder $_POST["folder_name"]
        put "Folder " & $_POST["folder_name"] & "created"
    else
        put "Folder " & $_POST["folder_name"] & "Exists"
    end if
break

case "retrieve_file"
    put URL ("file:" & $_POST["file_to_retrieve"])
break
case "update_file"
   put $_POST["new_data"] into URL ("file:" & $_POST["file_to_update"])
break
default
   put "invalid request"
end switch


No thoughts about security on this, just a barebones idea..

Now, for the curiosity question.. Would a database back end work better for
this?  (You'd still need an intermediary script)

On Mon, Sep 19, 2016 at 8:40 AM, Graham Samuel <livfoss at mac.com> wrote:

> I have some server space and a domain name, let’s say ‘mysite.com <
> http://mysite.com/>’. On this host I have a web site (www.mysite.com <
> http://www.mysite.com/>), plus LiveCode Server (8.1 commercial as it
> happens) and some scripts etc. So far, so good. Now I want to write a
> script that runs on the server and does the following - this is not code,
> but is supposed to show what I want to code:
>
> 1. If there is not a folder within my space called ‘myUsefulData’, then
> create such a folder;
>
> 2. If there is not a text file ‘myCurrentData.txt’  within the above
> folder, then create one (this may not be necessary, as an attempt to access
> the file might create it?);
>
> 3. Read the contents of the file into a variable;
>
> 4. Add some data from within the program (let’s say an extra line at the
> end);
>
> 5. Rewrite the updated file.
>
> There may also be error checking etc.
>
> Although this seems extremely simple, I find I don’t know how to do it,
> and so far the LC examples I’ve read don’t seem to help. I am not sure for
> example if FTP comes into the equation (I think it does) or the user name
> and password I need for FTP access from outside the server (surely not?),
> or indeed what the path to my own bit of the server actually is. Of course
> I’ve tried stuff, but nothing has worked so far, and a test script (running
> in the IDE, not within a server script) fails silently. Nothing is created,
> nothing is destroyed, but sadly everything isn’t transformed.
>
> Can anyone explain how to do this, or at least point me to an explanation.
>
> Sorry for the dumb question, but there it is.
>
> Graham
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list