-1

Working with the GCP Google CLI, specifically the "cp" method to copy files. I need to call it programatically, but can't find the executable to invoke.

Due to limitations in the project, really don't want to call cmd.exe and pass an arg to it like "gsutil cp sourceFile destinationFile".

Where is the executable located?

  • 1
    If I may ask ... if your goal is to copy GCS objects from one bucket to another and you are wanting to do this from within an application, have you considered using one of the many APIs available to do this directly without invoking a process level heavy command? Here is an example of using REST to copy objects: https://cloud.google.com/storage/docs/json_api/v1/objects/copy – Kolban Jun 29 '20 at 18:19
  • I hadn't considered a REST option as we have a fair bit of working code that runs GSutil CLI commands, but not from the middleware layer. Said middleware layer is capable of calling an executable and sending args. First choice is of course to call the executable directly of course. Plan B is to call cmd.exe and send args like "gsutil cp myfile sendFileHere". However, calling cmd is not working, and not generating errors in any logs. After a couple hours of trying to sort through mystery failures, decided maybe someone might know where an executable is. I may have to go REST as you say tho. – Mark Gregory Jun 29 '20 at 18:36
  • Linux has a command `which` that tells you the path to a program. Add the option `-a` to see all locations: `which -a gsutil`. The `cp` option is not a separate program, it is part of the CLI `gsutil`. If you do not want to call the program directly, then you will need to write your own code in its place. Note that `gsutil` is a Python script and not an executable. – John Hanley Jun 29 '20 at 21:08
  • Any reason for not using client libraries for GCS? For every popular languages it is available. You can use it and it works same as CLI. – ARINDAM BANERJEE Jun 29 '20 at 21:45

1 Answers1

0

By default the binaries on windows are on: "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin", however in order to do it programatically I suggest you to use the client libraries, it's even easier that implementing your REST api consumers.

Emmanuel
  • 1,436
  • 1
  • 11
  • 17