Using revCopyFile from server to laptop

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Using revCopyFile from server to laptop

Post by johnmiller1950 » Wed Feb 06, 2013 6:08 pm

Greetings All,

I am trying to write a script that will sync a text file from our company's server to a laptop.
I want to keep the creation date, last modified date and the last accessed date intact.

-- fileXX = location of file on server
-- fileYY = location of folder on laptop

If I use "put URL("File:" & fileXX) into URL("File:" & fileYY & "/" & filename)" the file is copied correctly, but I lose the attributes I want.

However, if I use "revCopyFile fileXX,fileYY nothing is copied and I get error = 1 in the result.

Using the revCopyFile command to copy a file from one place to another on the laptop works fine.

Does anyone know if there is a problem using the revCopyFile command to copy from a server?

Thanks for your help.

John Miller

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Using revCopyFile from server to laptop

Post by Simon » Thu Feb 07, 2013 12:20 am

Hi John,
Just checking... when you say "server" do you mean something like http://www.misite.com or do you mean a local server?
Reading in the dictionary there is no reference in the "Notes" section that says revCopyFile uses the internet library which implies that you can not use it for http requests.
Other then that use absolute path always.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Re: Using revCopyFile from server to laptop

Post by johnmiller1950 » Thu Feb 07, 2013 2:12 am

Simon,
Thanks for responding. I am not familiar with the terminology you are using, but the server is a dedicated machine in our company's office. It holds all our database files, etc.

The address I am using to access it is ("//Server/ke estimator folder/" & textfilename.txt"

This address works when I open my text files, but doesn't seem to work with the revCopyFile command.

John

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Using revCopyFile from server to laptop

Post by Simon » Thu Feb 07, 2013 2:46 am

Hi John,
I'm not completely sure but it may be the spaces in the folder name.
First thing to try is making a folder and file on your server without spaces in the name.
If that works then urlEncode (see in the dictionary) your server path to replace spaces with "+"

I think there are some faults with revCopy and you may have to use "put URL". If that is the case on Windows you can set the attributes after you have downloaded the files using "getshell("attrib +R +A pathToFile")" where +R is read only and +A is archive (google Windows cmd for full descriptions) and pathToFile is the path to the downloaded file.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Re: Using revCopyFile from server to laptop

Post by johnmiller1950 » Thu Feb 07, 2013 12:29 pm

Simon,

Thanks for the suggestions. I'll give it a try later today and let you know how it went.

John

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Re: Using revCopyFile from server to laptop

Post by johnmiller1950 » Thu Feb 07, 2013 2:54 pm

Simon,

Good News !!! I tried using the URLencode for the file location on the server, like you suggested. That DIDN'T work, but your comment got me thinking.

Usually, live code doesn't discriminate between foward slashes and back slashes in a file address. This keeps things simple between Mac and Windows programs.

On a windows machine, using the forward slash works fine when using revCopyFile to copy a file from one location to another on the same machine. However, the same practice does NOT work when copying a file from a server.

On our server, the address has to use back slashes. So here is my new script.

put the serverfileLoc into fileAA
replace "/" with "\" in fileAA
put folderDestinationLoc into folderBB
revCopyFile fileAA,folderBB

Well, I got revCopyFile to work, but after all this, I found that the modification of my files is changed when the copy is made, which I didn't want.
So, to accomplish my goal, it is much faster to use -- put URL("File:" & fileToCopy) into URL("File:" & folderBB & "/" & filename)

Ah, so goes my life in programming!!!

Simon, thanks for your help in figuring this out.

John

Post Reply