-1

I'm using R studio and try to connect to an office server using SSH. It's connected but my R working dictionary is still local on my laptop. May I ask how I could set the working dictionary to the remote server? Any advice is welcome. Thank you!!

Jane
  • 91
  • 4
  • You could create a bash script that uploads changed files via scp. – Lajos Arpad Aug 12 '21 at 18:37
  • Thank you Lajos! I never use that before... Could you be more detailed like how to create it? – Jane Aug 12 '21 at 18:58
  • Jane, I have provided you a PHP example in my answer. You can use any language for this purpose. Whenever you want to test, just run the script before it. – Lajos Arpad Aug 12 '21 at 19:07
  • I see! I will try that. Thank you! – Jane Aug 12 '21 at 20:26
  • You are welcome. Sidenote: this is an ad hoc code, so if it does not work out-of-the-box, then we can discuss the problems you may encounter. I have taken an actual script that works for me, which is much more complicated than the code given, deals with many projects and stripped down lots of details that's unnecessary for this question and did not test the result. If it does not work yet, don't worry. – Lajos Arpad Aug 12 '21 at 20:33

1 Answers1

0

You could write some script that uploads the files that are in git staging via scp. In PHP you could do something like this:

$rawFiles = shell_exec("git status --porcelain");
$files = explode("\n", $rawFiles);
foreach ($files as $file) {
    if ($file) {
        $filename = substr($file, 3);
        $command = "scp {$filename} user@your.url:/{$path}";
        shell_exec($command);
    }
}

and then execute this via CLI. It's a good idea to initialize all the variables above with parameters.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175