bash

What's the best way to escape a bash command in python?

What's the best way to escape a bash command in python? Question: I have a function that takes in a command as a string, and runs it on an AWS container using the aws binary. The command adds a few extra symbols before and after the command the user requested to run – I won’t …

Total answers: 1

strstr() alternative for bash

strstr() alternative for bash Question: I need to search a string for a substring, if the substring is found print the string upto the end of the substring.i.e str="this is a long string" substring="long" expected="this is a long" I have tried bash string manipulation and failed. Tried to use an awk command, but I can’t …

Total answers: 3

How do I get rid of b' if I want to parse a bash output using python?

How do I get rid of b' if I want to parse a bash output using python? Question: At my python application I’m doing the following to get some values from a larger JSON ffgrading_json = exec_command(f'{options["path_ffprobe"]} -loglevel quiet -print_format json -read_intervals "%+#2" -select_streams v:0 -show_entries side_data "{path}" | egrep -m 1 -A 10 "Mastering …

Total answers: 1

Is there a way to introduce a temporary wildcard in Snakemake from a list?

Is there a way to introduce a temporary wildcard in Snakemake from a list? Question: I recently started using Snakemake. I am building a pipeline where the goal is to separate fractions of reads (based on their taxID by classification by Kraken2). I am having problems understanding how I may introduce a new wildcard based …

Total answers: 1

Raise Airflow Exception to Fail Task from CURL request

Raise Airflow Exception to Fail Task from CURL request Question: I am using airflow to schedule and automate Python scripts housed on a Ubuntu server. The DAG triggers a CURL request that hits a Flask API on the same machine which actually runs the script. Here is a high level overview of the flow: Airflow …

Total answers: 1

Updating python variable name using Sed in shell script

Updating python variable name using Sed in shell script Question: I have a py file where we need to update the value of a variable table_name from a shell script using sed. The value will be like $ENV_NAME_ref_table considering we have already exported ENV_NAME as export ENV_NAME=’staging’. What should be the sed command? I have …

Total answers: 1

How to run bash script with getopt included in python?

How to run bash script with getopt included in python? Question: I am running a script in the ubuntu terminal and it works fine. ./run_script2.sh -b ./exercises/13_caching.py I want to run the same script in python os or subprocess but I am getting an error : ./run_script2.sh: line 36: getopt: command not found On line …

Total answers: 1

How to extract a key value from json file (python)

How to extract a key value from json file (python) Question: I’m trying to write a program that extracts all labels from a given JSON file: {"menu": { "header": "SVG Viewer", "items": [ {"id": "Open"}, {"id": "OpenNew", "label": "Open New"}, null, {"id": "ZoomIn", "label": "Zoom In"}, {"id": "ZoomOut", "label": "Zoom Out"}, {"id": "OriginalView", "label": "Original …

Total answers: 3