Print Works As Return Statement When Fetching Values In Bash From Python Scripts

# BASH
var=$(python3 foo.py)

1. notes

  • the answer is that the print statement within Python is assignable to a variable in Bash
config_type=$(python3 ./configure_EMR.py --size "1024000000")
echo $config_type
EMR config set to type 6
  • in addition, I need to get only the integer from that string
  • Then, use parameter expansion to delete everything except the numeric value
config_type=$(python3 ./configure_EMR.py --size "1024000000")
config_type=${config_type#"EMR config set to type "}
echo $config_type
6
  • Of course, this is the most simplistic answer but I am happy its possible

2. links

--

--

--

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Cut Yourself Some Slack From Slack

CS371P Spring 2021 Week 6: Irena Lee

How to use Windows on Your Mac — Dual Booting using Bootcamp

The cost of an architectural decision

Different diagrams about a plug-and-play architecture

Haskell: Fibonacci in O(n) time

Flutter: Firebase setup for Android & iOS | Complete Guide

Thank you WordPress for helping me find digital accessibility

How to Receive Order Notifications on Slack from An Open Source Ecommerce Store

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Pavol Kutaj

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

More from Medium

Understanding Shell scripting

How To Install Postgresql In Linux?

Linux CPU Context Switch Deep Dive

Linux: how to end to end verify UDP and TCP connectivity with nc