• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for November 2022

Open Browser in Bash

November 30, 2022

Here’s a nice little command to open a browser from Bash.

#!/bin/bash
open https://domain.com/path/to/web/page/index.html

#!/bin/bash open https://domain.com/path/to/web/page/index.html

You can use this command to open a web page from your script.

Filed Under: HTML, Linux Tagged With: bash, browser, open

Bash Any Key

November 29, 2022

Here’s the script to add pauses in your Bash script.

echo "please wait until web page loads ... "
read -p "Press any key to continue... " -n1 -s

echo "please wait until web page loads ... " read -p "Press any key to continue... " -n1 -s

You can also put it inside a function and call it multiple times.

function press_any_key {
  echo "please wait until web page loads ... "
  read -p "Press any key to continue... " -n1 -s
}
press_any_key

function press_any_key { echo "please wait until web page loads ... " read -p "Press any key to continue... " -n1 -s } press_any_key

Filed Under: Linux Tagged With: any, bash, key, pause, press

Crontab on macOS Monterey

November 29, 2022

A recent OS upgrade rendered the crontab to malfunction on macOS Monterey. It turned out the system just needed a reset of System Preferences > Security & Privacy > Privacy tab, and to make sure cron has full access to disks. Once you flipped that, your crontab should start working. Hope that helps.

Filed Under: Linux Tagged With: cron, mac os, monterey, reset

Crop Factor Calculator

November 13, 2022

If you’re into photography, you would know what crop factor means. I have a Nikon D90 camera with a crop factor of 1.5. For example, if you use a 24mm full frame lens on a D90, the focal length will be 36mm. So, here’s a handy bash script that calculates the crop factor by multiplying the full frame focal length by 1.5.

#!/bin/bash
if [ $# -eq 0 ]
  then
    echo "Usage: cropfactor.sh 24"
    exit
fi
a=$(echo "1.5 * $1" | bc)
echo "Cropfactor focal length is: " $a"mm."

#!/bin/bash if [ $# -eq 0 ] then echo "Usage: cropfactor.sh 24" exit fi a=$(echo "1.5 * $1" | bc) echo "Cropfactor focal length is: " $a"mm."

Result

ulysses@penguin:~/Code$ ./cropfactor.sh 24
Cropfactor focal length is:  36.0mm.

ulysses@penguin:~/Code$ ./cropfactor.sh 24 Cropfactor focal length is: 36.0mm.

Filed Under: Linux Tagged With: 1.5, bash, crop, d90, factor, nikon

  • Home
  • About
  • Archives

Copyright © 2023