Google Cloud Shell: How to interface via command-line terminal? - linux

I created a very simple python hello_world script on the google cloud shell. I implemented it and ran it within the in-browser google cloud shell and it compiled and outputted correctly.
My question is, what if I want to implement this same hello_world script via a linux server I am on? I currently just downloaded the google SDK and did a 'gcloud init' and set up this hello_world python project onto my linux server by following the google cloud documentation:
https://cloud.google.com/sdk/docs/quickstart-linux
https://cloud.google.com/sdk/downloads
I am just a little confused on how to access these files on my linux server terminal and run them via linux server terminal. I simply want to run them on here and have the same output as I did on the google cloud shell via the in-browser console.

If I'm reading this right, you can simply download the files over to you system. When you have the shell open, the upper right corner there is the 'more' option and from there you will see the ability to download files directly. Sorry, if this isn't what you were looking for.
Rick

Related

Is there a way to schedule a python script (the script uses Google API to read google sheets) using crontab?

I am trying to schedule a python script using crontab on a web server, but the file doesn't run at all. The script uses Google API to read google sheets. Other files that don't use Google API run as expected. Why is it so?

Drag'n'Drop local file to browser window via Command Line for uploading

Not quite sure if it possible at all, so decided to ask here.
I need to automate some things and search the way to drag'n'drop local file to browser window (with specific URL) via Terminal command for uploading.
I use Mac, but I think Linux will fit here as well.
If there is any solution or module on Bash / Python / Node.js I will gladly give it a try.
take a look at requests package in python language.
you can make a POST request and send information you want to the web server.

Output to local file using cloud shell in vscode on a MAC

I am new to VSCode on a Mac and I am using the Cloud Shell connected to Azure where I can run all my commands without issue. The problem I have is that if I want to use the export-csv command to export the information to a file I don't know how to point the output file to the Desktop of my Mac.
Is this possible or am I barking up the wrong tree?
When you are using cloud shell all data is executed remotely on azure terminal so the cloud is saved to a blob storage, you can run export-csv command then download the data from the blob storage.
for more details :
https://learn.microsoft.com/en-us/azure/cloud-shell/persisting-shell-storage

How to download a folder to my local PC from Google Cloud console

I have a folder I want to download from Google Cloud Console using the Linux Ubuntu command terminal. I have logged in to my SSH console and so far I can only list the contents of my files as follows.
cd /var/www/html/staging
Now I want to download all the files from that staging folder.
Sorry, if I'm missing the point. Anyway, I came here seeking a way to download files from Google Cloud Console. I didn't have the ability to create an additional bucket as the author above suggested. But I accidently noticed that there is a button for exactly what I needed.
Seek keebab-style menu button. In the appearing dropdown you should find Download button.
If you mean cloud shell, then I typically use the gcp storage tool suite.
In summary, I transfer from cloud shell to gcp storage, then from storage to my workstation.
First, have the Google cloud ask installed on your system.
Make a bucket to transfer it into with gsutil mb gs://MySweetBucket
From within cloud shell, Move the file I to the bucket. gsutil cp /path/to/file gs://MySweetBucket/
On your local system pull the file down. gsutil cp gs://MySweetBucket/filename
Done!

How to edit google app script outside of the browser, e.g., in emacs or vim?

I want to edit GS (google app script) files in a decent editor (Emacs or VIM) and keep it under git, so I need to be able to install it to run it.
Right now I copy the whole file and paste it into the code window in the browser, which is clearly suboptimal.
I wonder if there is a way to do it.
For some reason, Edit With Emacs does not work with the script editor.
The google apps script
Importing and Exporting Projects guide details using the Drive REST API
Note: Import/Export of scripts is limited to Standalone scripts
Only standalone scripts can be imported or exported. Container-bound scripts cannot be accessed through the Google Drive REST API.
This Google repo details how to work with scripts in a local dev environment
It uses node-google-apps-script which is really all you need to import/export your script project to a local machine and back to Google
It is a little bit of work setting it up; there are quite a few steps to work through
Despite this question is a bit old, I consider it could be useful for someone still wanting to edit App Scripts outside the browser.
There is a tool named clasp which aims to provide a way to edit an app script project in a local environment: https://github.com/google/clasp.
You just need to install via:
npm install -g #google/clasp
And enable the Google Apps Script API: https://script.google.com/home/usersettings
To use it, you should include a package.json via npm init (tested with version 2.4.0) and then make:
clasp login
clasp clone "projectID"
Afterwards, you could edit the files with your favorite editor. Finally, you could push the changes via:
clasp push
For more information, please check the repository of the project, pointed out above.

Resources