Page 1 of 1
Write to file using a FTP
Posted: Thu Nov 26, 2015 3:04 am
by JackBroughton
Hi All,
I am building a routine that gets an order number from a text file on a server through FTP, increments that order number then saves the new, incremented order number back to the file.
I am stuck on the saving part. Here is my basic code. It gets the correct data out of the file, increments it but how do I put the new order number back?
Code: Select all
put "ftp://"&" UNAME "&" : "&" PW "&"@"&" IP "&"/test/System Numbers" into tFolder
put (tFolder & "/" & sPoint) into nFile
put url nFile into tNumber
add 1 to tNumber
put (sCode & tNumber) into line 1 of url nFile
This was the only similar post I could find but there was no solution that worked and the responses stopped in 2010.
http://forums.livecode.com/viewtopic.ph ... FTP#p60212
Re: Write to file using a FTP
Posted: Thu Nov 26, 2015 3:39 am
by Simon
Hi Jack,
Unless you have some cool php, cgi or a liveCode server I don't think just FTP is what you want.
If the file was small enough and wasn't being requested by multiple users then I'd download the file, update it locally then upload it again.
Simon
Re: Write to file using a FTP
Posted: Thu Nov 26, 2015 3:58 am
by JackBroughton
Hi Simon,
Thank for you reply. I thought as such.
It is a tiny file (4kb's) but I do have multiple users accessing it.
Currently it is working as we mount the server using AFP then uses a Open, Write and Close process on the file. I wanted to try mimic that so we can move to mobile devices.
I think I will try using a php script to do it server side.
Regards
Jack
Re: Write to file using a FTP
Posted: Thu Nov 26, 2015 4:04 am
by Simon
Hi Jack,
This actually sounds like a job for mySQL, if you haven't worked with DB's this would be a great start. Simple DB, the most difficult part would be setting up the original DB on your server and cPanel can do most of that.
Simon
Re: Write to file using a FTP
Posted: Thu Nov 26, 2015 10:33 pm
by AndyP
Hi Jack,
Have to agree that this sounds like a db is the way to go. MySQL can handle concurrent actions from multiple users with ease.
If have LiveCode server installed on your hosting then you can use LiveCode to act as the parser to and from the db.
All the code you would need for this can be found here:
http://activethought.net/livecode-server/databases/
I'm using LiveCode server in a few of my projects serving around 200 users and have found the speed (in most cases) comparable with PHP.
All the best on your LiveCode explorations...
Re: Write to file using a FTP
Posted: Fri Nov 27, 2015 5:30 am
by JackBroughton
Hi Simon and Andy,
Thank you for the suggestions to use SQL and I may look at moving to a SQL DB soon.
As for my initial issue I found a very simple fix. In the below line, FTP has an issue with folders that have a space in them.
Code: Select all
put "ftp://"&" UNAME "&" : "&" PW "&"@"&" IP "&"/test/System Numbers" into tFolder
As soon as I changed System Numbers to SystemNumbers it all worked fine.
Code: Select all
put "ftp://"&" UNAME "&" : "&" PW "&"@"&" IP "&"/test/SystemNumbers" into tFolder