Skip to content

Instantly share code, notes, and snippets.

@DiannaHohensee
Last active March 17, 2023 21:02
Show Gist options
  • Save DiannaHohensee/0e8765f9ef2661d1c6ffaaf65e74d029 to your computer and use it in GitHub Desktop.
Save DiannaHohensee/0e8765f9ef2661d1c6ffaaf65e74d029 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Invocation to get all the validate logs for the groupIds/ClusterNames present in a .csv file using this script:
# awk -F',' '{ if (NR>1) atlas_cmd="./script.sh "$1" "$2" file-directory-name" system(atlas_cmd)}' input.csv
#
# The above invocation skips the first line (NR>1) because the first line of a .csv file is column names.
# Replace file-directory-name with whatever file directory the validate files should go in. For some reason
# the awk invocation adds a '0' to the end of the directory name.
#
# Requirements:
# First edit the input.csv file and add an empty line at the end of the file. Otherwise the last line is skipped for some reason.
# Takes a 'groupId', 'clusterName' and 'directoryName' as command invocation arugments and pipes the result to a text file named
# "<directoryName>/<groupId>-<clusterName>.txt>
#
# Invocation:
# ./s.sh <groupId> <clusterName> <directoryName>
#
# Notes:
# If the directory already exists, the python code will still go ahead: execution is not aborted.
# If the data file already exists in the specified directory, it gets overwritten (I think).
# Expected that the "pubkey" is set in the ~/.adv file.
if [ "$#" -ne 3 ]; then
echo "Expected 3 arguments"
exit 1
fi
if [ ! -d "$3" ]; then
mkdir $3
echo "Created directory ${3}"
fi
runFunc () {
echo "arguments: "$1" "$2" "$3
python3 main.py --atlasUrl "https://cloud.mongodb.com/" get --groupId $1 --clusterName "$2" > "${3}/${1}-${2}.txt"
}
runFunc $1 $2 $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment