Why does copying to server not work

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

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Why does copying to server not work

Post by sphere » Mon Oct 06, 2014 1:57 pm

Hello,
i'm trying to copy a file to a server, i need no special rights.
Copying via windows goes well, i can select a local file and drag it to the folder on the server. I even can delete it again.
Now i though't that revcopyfile does the same as windows does?
Well i tried revcopyfile, i tried put. but nothing works. i even checked the address with a folder check tool which is available via the examples or resources here and it's correct. it gives //serverblabal/folderblabla/

I open a file and put it into a global:

Code: Select all

global gPathS

on mouseUp
      answer file "open file" with type "PDF document|pdf|PDF" or type "JPG document|jpg|JPG"
   if it = empty then exit mouseup
   put it into gPathS
     end mouseUp
then i let it answer so i know the file is in the global, just a check. and then i try to copy(or upload) it, but it just don't work:

Code: Select all

global gPathS

on mouseUp
    answer "gPathS = " & gPathS

 put url("binfile:" & gPathS) into URL "binfile://serverblabla/folderblabla/" -------don't work

#put url("binfile:" & gPathS) into URL "binfile://serverblabla:8080/folderblabla/"--------don't work

#put gPathS into URL "binfile://serverblabla/folderblabla/"--------don't work

#put gPathS into URL "binfile://serverblabla:8080/folderblabla/"--------don't work

#put gPathS into URL ( "file://serverblabla/folderblabla/")------------i tried this, don't work

#revCopyFile gPathS,URL"binfile://eufrka203p/SampleShippingForms/" -------------don't work

#revCopyFile gPathS,URL"binfile://eufrka203p:8080/SampleShippingForms/"------------don't work

#revCopyFile gPathS,"//eufrka203p/SampleShippingForms/"------------don't work

answer "done"
end mouseUp
anyone an idea why i does'nt work?

i don't get it anymore

Thanks a lot for helping me solve this.
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

Klaus
Posts: 11103
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Why does copying to server not work

Post by Klaus » Mon Oct 06, 2014 2:06 pm

Hi sphere,

are we talking about a WWW server?
If yes, then you cannot just copy something to the server, that will require a ServerSideScript (CGI)
to retrieve and save the file on the server. will

Code: Select all

on mouseUp
      answer file "open file" with type "PDF document|pdf|PDF" or type "JPG document|jpg|JPG"
   if it = empty then exit mouseup
   put it into gPathS
     end mouseUp
HINT:
When the cursor is in a handler in the script editor, please hit ENTER from time to time!
That will make LC format and indent the script nicely:

Code: Select all

on mouseUp
   answer file "open file" with type "PDF document|pdf|PDF" or type "JPG document|jpg|JPG"
   if it = empty then exit mouseup
   put it into gPathS
end mouseUp
Best

Klaus

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Mon Oct 06, 2014 2:19 pm

Hello Klaus,

thank you for your suggestions.
As far as i know it is not a WWW server. The server is from the company i work and resides in Germany (i'm in NL). But i can reach the folder from within the Windows system i'm logged into.
Copying from a local explorer window to the window of that server folder is working normal, like it would be another local folder.

I will check if there is allready such a script.

Thank you for your help.

Best regards.
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

Klaus
Posts: 11103
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Why does copying to server not work

Post by Klaus » Mon Oct 06, 2014 2:25 pm

Hi sphere,

ah, OK, just wanted to be sure if this is an internet server or not.

No idea what is going wrong, but a "server" that you can "mount" to your filesystem
should be accessible the usual way with revCopyFile or "put url("binfile:...") into url("binfile:...").

Sorry, no idea actually...


Best

Klaus

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Mon Oct 06, 2014 2:45 pm

Ok thanks Klaus.

Maybe i can find some info internally on how to solve this.
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

Klaus
Posts: 11103
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Why does copying to server not work

Post by Klaus » Mon Oct 06, 2014 2:55 pm

Hi sphere,

maybe you can do something like this, to see what LC requires as a correct pathname for copying.
Use the message box or any button with this script:
...
answer file "Seelct a file on the server:"
put it
...
then in the open dialog, select a file from that namely server and see what the message box shows as the filename.
Know what I mean? Maybe it is just a wrong "address" so far?


Best

Klaus

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Mon Oct 06, 2014 5:03 pm

Hi Klaus,

i did somthing like that with a program from the sample stack, called filePath. You can drop a file on it and it gives the filepath.
and it gave //servername/foldername

but i can try yours tomorrow and let you know

thanks!
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm
Location: Greece

Re: Why does copying to server not work

Post by zaxos » Mon Oct 06, 2014 6:33 pm

Code: Select all

on startCopy
put "robocopy /E" && quote & sourcePath & quote && quote & destFolder & quote into commandToExec
launch commandToExec
end startCopy
I use robocopy for every copy task on windows since its fast and it requires no additional software, try it and you will be surprized :)
Knowledge is meant to be shared.

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Mon Oct 06, 2014 7:10 pm

ok thanks Zaxos
i will try it tomorrow on my work too

so i can fill in my locations? just like url(binfile:"//servername/location/")
and why the words quote, i read something that else you get errors




i can't try it at home

Thanks a lot! maybe it will work !
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Tue Oct 07, 2014 12:52 pm

Hi
i tried a few things. it seems that in the dos command box just COPY is also working like this:

Code: Select all

 copy c:\temp\blabla.pdf \\serverblabla\folderblabla\ 
works ok

Code: Select all

startCopy
    
    answer "done"
end mouseUp

    # robocopy test
    on startCopy
       #put "robocopy /E" && quote & sourcePath & quote && quote & destFolder & quote into commandToExec
       put ("copy" && quote & gPaths & quote && quote & "//serverblabla/folderblabla/") & quote into commandToExec
       answer ("copy" && quote & gPaths & quote && quote & "//serverblabla/folderblabla/") & quote
launch commandToExec
end startCopy
so i tried a few things but the asnwer thingy is giving me this:
copy c:/temp/blabla.pdf //serverblabla/folderblabla/

this is not working when you type this in the dos command promp
also this is not working:
copy c:\temp\blabla.pdf //serverblabla/folderblabla/
and this also not
copy c:/temp/blabla.pdf \\serverblabla\folderblabla\
so it has to do something with the slashes.

so how can i change the / into \ when a file is opened or put into a local or global?

Code: Select all

global gPathS

on mouseUp
   
   answer file "open file" with type "PDF document|pdf|PDF" or type "JPG document|jpg|JPG"
   if it = empty then exit mouseup
   put it into gPathS
      
  end mouseUp
i think this is the bottleneck why it is not copying via the dos command
any help on this how to change it would be highly appreciated

thanks !
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

Klaus
Posts: 11103
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Why does copying to server not work

Post by Klaus » Tue Oct 07, 2014 1:01 pm

Hi pshere,

yep, internally LC ALWAYS uses the UNIX SLASH/ as a path delimiter.
But when you use SHELL on windows, this demands the windows native BACKSlash \

But just like you would explain in plain english, you can always:

Code: Select all

global gPathS
on mouseUp  
   answer file "open file" with type "PDF document|pdf|PDF" or type "JPG document|jpg|JPG"
   if it = empty then exit mouseup
   put it into gPathS  

   ## You can do this right here, or later before you need to use the path with windows SHELL   
   replace "/" with "\" in gPathS
   ## Easy-peasy, innit? :-D
end mouseUp
Best

Klaus

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Tue Oct 07, 2014 2:45 pm

Hello Klaus,

yes that was quiet simple indeed, i did not know it could be so easy.
now i come to some other issues which also maybe the case why it is not being copied.

the robocopy function requires:
robocopy sourcefolder destinyfolder filetocopy----this works in the dos box

this is not working:
robocopy sourcefolder\filetocopy destinyfolder

when i use livecode none of the copy or robocopy or xcopy are working.
When i use the answer function to display how the string is send to the dos command then i see also the " characters, so are the " possibly also send to the dos command?
then maybe thats why it is not working?

in the answer box is the copy string is: copy "C:\temp\file.pdf" "\\serverblabla\folderblabla\"

now i removed the words QUOTE in the line and added a SPACE like this :

Code: Select all

put "robocopy /E " & sourcePath  & " \\serverblabla\folderblabla\"  into commandToExec
now robocopy seems to need more time, just like in the dos prompt itself it needs some more time than copy or xcopy

so it looks like it getting the command without the " around it but still its not working

any other idea maybe?

thanks a lot!
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Tue Oct 07, 2014 3:37 pm

Hi Klaus or anyone who can help,

i'm starting to get results with the robocopy thingy

Code: Select all

on mouseUp
 put "robocopy " & "c:\temp\"  & " \\serverblabla\Folderblabla\" & "1-pdf.pdf"  into commandToExec
       
launch commandToExec
end mouseUp
now this is creating a folder 1-pdf.pdf on the server and puts all files which where in the c:\temp folder in it, so that's strange, it's a good start but it's strange

so going to test with some of the / command after robocopy which are shown with robocopy/? in dos box

thanks
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

sphere
Posts: 899
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Why does copying to server not work

Post by sphere » Tue Oct 07, 2014 3:50 pm

haha ok i got it now!

Code: Select all

on mouseUp
 put "robocopy /MOV " & "c:\temp\"  & " \\serverblabla\folderblabla\"   into commandToExec
       
launch commandToExec
end mouseUp
So i removed the filename which has to be copied.
now it just copies all files which are in the source folder to the server folder (i don't know why but it does)
the /MOV command deletes the file in the source folder

so now i have to make sure that my source file will be copied in a folder with no other files, so then it will be the only which is going to be moved to the server.

Klaus and Zaxos thank for getting me on the right track!
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

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

Re: Why does copying to server not work

Post by Simon » Tue Oct 07, 2014 5:40 pm

Hi sphere,
Sorry you have to go to robo thingy.
LiveCode copies files fast and you don't have to shell out:

Code: Select all

on mouseUp
   set itemDel to "/"
   answer file "pick one"
   put it into tCopyFile
   put the last item of tCopyFile into tName --need just the filename
   put url("file:" & tCopyFile) into url("file://myServer/path/folder/" & tName)
   put the result
end mouseUp
In you examples you didn't separate out your filename.

But you got your code working so probably I'm just making noise here.

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

Post Reply

Return to “Talking LiveCode”