Silver.Rainbow
Silver.Rainbow

Reputation: 435

How to list file names on a remote unix server in r?

I created a session and can execute the ls command

library(ssh)
session<-ssh_connect("[email protected]", keyfile = "my private key")
ssh_exec_wait(session, command = 'ls /home/')

This results of the ls command displayed in rstudio console and the function returns 0.

So this does not work

varFileList<-ssh_exec_wait(session, command = 'ls /home/')

How do I accomplish this?

Upvotes: 2

Views: 486

Answers (1)

Silver.Rainbow
Silver.Rainbow

Reputation: 435

Found the answer

varFileList<-capture.output(ssh_exec_wait(session, command = 'ls /home/'))

Upvotes: 2

Related Questions