Launch a webpage from a ChromeBook secure shell script? - bash

I've got an AWS instance running Jupyter that I use for general mucking around, and tend to shut it down when not in use. Shutting it down changes the IP and the DNS name. On the Mac, I have a simple script that uses the AWS CLI to grab the current IP of the instance and use that to open the Jupyter notebook in Chrome.
I'm trying to replicate the same functionality on a ChromeBook. I've been able to get the shell running, get the AWS CLI running, but can't figure out how to do the last bit, which is to open the URL in Chrome. (In other words, do the equivalent of the OSX Bash command open -a "/Applications/Google Chrome.app" http://1.2.3.4:8888 on the ChromeBook shell.
So basically I want to know how to open an arbitrary URL in Chrome from the ChromeBook shell.

My Chromium OS machine has xdg-open. If your version has that, it'll be the easiest thing.
xdg-open http://1.2.3.4:8888
If not, you can always just call the full path of Chrome with the url as a parameter, (e.g. chrome http://...) or consider the many options provided here.

Related

How to scrape data from an internal browser page such as "brave://rewards"

Overview
My goal is to write a Bash script on WSL2 that pulls data from the Brave browser's home page and stores it in a text file. Specifically, I would like to access the value for 'Brave Rewards' seen in this picture and store it in a Bash variable:
Issue
I can't figure out how to access this page programmatically. There's no URL that I can use to download it with wget or curl. All I can find is brave://rewards/, which doesn't work from curl or wget:
# ISSUE GETTING CONTENTS
content=$(wget brave://rewards/ -q -O -)
echo $content
# Blank line returned
The browser is the Windows version, which I can launch either from the shell on WSL2/Ubuntu (via xlaunch) or directly from Windows.
Is there any way that I can programmatically access the "Brave Rewards" value or the brave://rewards URL?
Unfortunately, this isn't something you'll be able to "scrape", as you seem to be trying. The brave://rewards page, as mentioned in the comments, is an internal browser page. You won't have access to this page from wget or any other software, regardless of whether it is WSL, pure Linux, etc.
The browser apparently communicates with api.rewards.brave.com to get this information, but as far as I can tell there is no documentation on that API.
There might be two possibilities for obtaining the information you want programmatically:
If you really want to "dig in", you can look at the source code (JavaScript and HTML) of brave://rewards from within the browser by starting the Developer tools (Ctrl+Shift+I). The main script is brave_rewards_page.bundle.js. It may be possible to reverse-engineer the script.
Perhaps a better option, depending on how often you would want to do this, is to attempt to script this via Python/Selenium/Chromedriver. Using this stack, you can "automate" the browser to open the brave://rewards page and access the contents of the <div> with the reward value.
Some tips for doing this from WSL2:
You will need to use the Linux version of Brave. Selenium on WSL2 won't be able to connect to the Windows Brave's chromedriver.
That means that you'll also need the ability to run GUI apps on WSL2. This can be most easily done if you have the ability to upgrade to Windows 11 with WSLg support. Alternatively, I prefer xrdp personally for accessing GUI apps in WSL2 on Windows 10. See this question and a separate answer I provided here for more details.

How to connect google cloud shell to termux app using ssh?

I am using google-cloud-shell which is basically a shell that allows us to use online cloud shell (for developing apps etc.) and provides 5gb of free storage (only for home directory).
It is a very cool thing because i don't have PC but google-cloud-shell allows me to run gradle, java, python, etc. without any issues except one issue and i.e typing response. Although it is a very good platform for learning coding but typing is insane.
If i type a character it takes about a second to be displayed on screen and it really really sucks. Now what i want is to connect this shell to termux (which is an app just like terminal in linux) with ssh or any other thing that can connect it.
NOTE: I am not using paid version of google-cloud-storage I am just using it cloud shell which is free to use.
You can use the following gcloud command to SSH into your cloud-shell from local terminal.
gcloud alpha cloud-shell ssh
You can find more details here

Run a shell command through a Chrome App

I have Crouton on my Chromebook with Spotify inside an Ubuntu chroot.
I can execute Spotify inside an Ubuntu chroot as a single app window via a Crouton command.
I want to create a Chrome OS application that acts as a launcher for Spotify, Skype, etc.
In short:
My Chrome OS app should execute a shell command.
I read about NPAPI, but it says it's getting depreciated (since 2013 o.O).
If there's another way (for example executing a bash script that adds a button to the shelf that just executes another shell script to open Spotify), it would also be great.
Thx in advance :)
EDIT:
With Dart this seems to be possible. It says "access File system, USB Devices, shells and much more" with it
Looks like Native Messaging is just the thing you're looking for! However you may need to create an application that can be registered as a Native Messaging Host. This application will then in turn call the shell command/script you intend to run.

Meteor: unexpected mongo exit code 100 when using ssh client on OS X

I've just installed Meteor 1.0 on my Ubuntu 12.04 VM in VirtualBox. After login via SSH from my OS X host and trying out the Meteor tutorial at https://www.meteor.com/try I get this exit code 100 from Mongo when I launch the example.
Here's the weird part, I only see this exit code 100 when I'm using OS X's terminal to SSH. If I try using putty on Windows or Chrome Secure Shell in my Chrome browser there is no problem. The Meteor app launches ok!
Is OS X's terminal/SSH implementation any different from putty or Chrome Secure Shell?
OSX ssh is a version of OpenSSH, which is essentially the reference version of ssh. It's extremely unlikely that it's doing something unique or different than putty which prevents mongodb from working.
It is possible that you're using ssh differently than you're using putty, and that's preventing mongodb from working. You haven't given us any information about exactly how you're running ssh, or what putty options you're using. So there's no way for anyone to help you with that.
There are numerous questions on this site about mongodb exit code 100. Common causes seem to be lack of disk space and inability to delete a lock file. If you were using a different ubuntu account when you connect from OSX vs putty, that could certainly cause trouble deleting a lock file, for example.

Upon executing a selenium test, spin new Windows VM, execute commands, then exit?

I am running a Mac but need to test Web applications in IE. Ideally, I would love to be able to execute a selenium command on my box, and it would spin up a VM (VirtualBox, VMWare, something like that), run the commands in IE, and then exit the VM once I'm done. Is that possible? If not, does anyone else have a better idea of how to run selenium commands in a Windows environment from a box that is not Windows? My commands are in Python 2.7, if that matters. Thanks
Your requirements shall be possible to fulfill.
Selenium can be using "Selenium Server" and your python code using selenium package shall be able talking to it - it uses http protocol for such a remote control.
Selenium server is using Java, and as it is started, it shows url on which it awaits commands.
These urls can be then used in your python code when constructing driver for your browser, there you specify url of remote Selenim server and shall be able continuing as if you would work locally.
Description how to connect is here.
Feel free to comment or reply to me how it went, it sounds very interesting but I do not have any real experience with that so far.

Resources