R - write() a file to a SAMBA share

爱⌒轻易说出口 提交于 2019-12-13 12:42:12

问题


I have a file loaded in R that I want to move to a samba share

It is something like

write(some-file, file = "|smbclient -U user //ip password")

It connects to the samba but then (I think) the output is "executed" in the smb: \> and I don't want the file to be executed, I don't know how to pass the file to the destination with a putfunction inside smbclient.


Edit: This is not the same problem as the first post. The first post is solved and answered by me. The point there was connecting to samba. Now I'm already connected to it but the write() function doesn't make a file, instead it pipes out the words separately. I just wanted to know how to make it create a file in a sentence.


回答1:


I found the answer by changing the philosophy:

First, I write the file locally, like

write(some-file, there)

Then I use the system() function to call smbclient and put the file already written

system("smbclient -U user //ip/dir password -c \"put some-file some-file\"")

My script is more complex and it's inside a Shiny app but in summary that's the solution



来源:https://stackoverflow.com/questions/30051162/r-write-a-file-to-a-samba-share

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!