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?

  • 1
    $\begingroup$ 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. $\endgroup$
    – MarcoB
    Jun 3, 2020 at 5:35
  • $\begingroup$ 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. $\endgroup$
    – C. E.
    Jun 3, 2020 at 6:57
  • $\begingroup$ @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. $\endgroup$ Jun 3, 2020 at 16:54
  • $\begingroup$ @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... $\endgroup$
    – MarcoB
    Jun 3, 2020 at 17:37
  • $\begingroup$ @MarcoB I just reached out to Wolfram Technical Support. Perhaps they can straighten this out. $\endgroup$ Jun 3, 2020 at 20:25


Browse other questions tagged or ask your own question.