2

I am trying to use databricks cli and invoke the databricks configure That's how I do it from cmd

  somepath>databricks configure --token
  Databricks Host (should begin with https://): my_https_address 
  Token: my_token

I want to invoke the same command using R. So I did:

  tool.control <- c('databricks configure --token'
                    ,'my_https_address'
                    ,'my_token')

 shell(tool.control)

I get the following error

  Error in system(command, as.integer(flag), f, stdout, stderr, timeout) : 
  character string expected as first argument

How can I correct it?

EDIT: After trying the suggestion in the comment, I get this error:

Databricks Host (should begin with https://): Aborted!
'https:' is not recognized as an internal or external command,
 operable program or batch file.
 'my_token' is not recognized as an internal or external command,
 operable program or batch file.
[[1]]
[1] 1

[[2]]
[1] 1

[[3]]
[1] 1

Warning messages:
 1: In FUN(X[[i]], ...) :
 'databricks configure --token' execution failed with error code 1
 2: In FUN(X[[i]], ...) :
  'my_https_address' execution failed with error code 1
 3: In FUN(X[[i]], ...) :
 'my_token' execution failed with error code 1
89_Simple
  • 3,393
  • 3
  • 39
  • 94

1 Answers1

0

The Help pages for system {base} say:

This interface has become rather complicated over the years: see system2 for a more portable and flexible interface which is recommended for new code.

Seeing as you didn't request that we specifically use shell() I presume you're okay with using system2() (?)

Anyway, I can't get it to be completely automatic sadly- adding the token as another input doesn't work strangely- but this gets you most of the way there.

Run the first command, and then insert the token, either by copying and pasting, or using Command+Enter (or Control+Enter) to have R do it for you, and hit enter.

system2("databricks", 
        args = "configure --token",
        input = "https://dbc-b6432663c-e88a.cloud.databricks.com") # the URL and token have been changed, these are just made up ones

asfewfwefaewfaefewfee898a98

system2("databricks", args = "workspace list")

"Users
Shared
Repos
spark_mooc_meta" # my workspaces

Hope this helps!

Mark
  • 7,785
  • 2
  • 14
  • 34