4

I would like to use Mathematica to create some simple web pages. I prefer not to use CloudDeploy because I can host these pages more cheaply locally and they have no interactivity. Generating a page is easy enough with Export["filename.html",#] and it seems as though uploading should be easy with a combination of CopyFile[] and RemoteFile[], specifically something like this:

destinationURL = URL["sftp://sterno.pairserver.com/test.txt"];
destinationRF = RemoteFile[destinationURL, 
   Authentication -> <|"Username" -> XXXX, "Password" -> YYYY|>];
CopyFile[FileNameJoin[{NotebookDirectory[], "test.txt"}](*from*), destinationRF(*to*)]

I’ve tried on two different servers — one local and one remote, both reachable by sftp and graphical sftp clients. I’ve tried specifying the destination filename and providing just the destination directory. If I specify the name, I get

::URL : Cannot open remote file: /test.txt

and if I don’t, I get

::URL : Cannot open remote file: /.

What am I missing?

Michael Stern
  • 4,695
  • 1
  • 21
  • 37
  • 1
    I think CopyFile could be useful. It supports an SFTP destination file. Since you have control on the destination server, maybe you could make that work. – MarcoB Jun 03 '20 at 05:35
  • It would be better to ask very specifically, "I want to use the FTP" or "I want to use SSH" etc. since we don't know what transfer protocols your server supports, so we can't answer the question in general. – C. E. Jun 03 '20 at 06:57
  • @MarcoB you are right that CopyFile ought to work. I’ve been trying incantations for the last hour and haven’t been able to get it to work yet over SFTP. – Michael Stern Jun 03 '20 at 16:54
  • @MichaelStern Yeah, not surprised unfortunately. I have only tried something like this once before but gave up in frustration when I couldn't get it to work, and every other "normal" tool would... – MarcoB Jun 03 '20 at 17:37
  • @MarcoB I just reached out to Wolfram Technical Support. Perhaps they can straighten this out. – Michael Stern Jun 03 '20 at 20:25
  • @MichaelStern Good idea. If you / they figure this out, it would be great if you could add a self-answer here explaining your solution. In case the question gets closed, we should be able to get it reopened for you to add an answer. – MarcoB Jun 03 '20 at 20:29

0 Answers0