bash

Trying to Load A Message Payload from a JSON File in Bash to Send to Slack Channel

故事扮演 提交于 2021-02-08 07:36:42
问题 So I am trying to send a message to a specific slack channel using a secrets.json file to specify the payloads for both messages and the web-hook URL. I am able to post things to the message but it does not load the message as a payload even though the payload variable is set correctly. How can I load message payloads within the curl command I am specifying? Here is the code: richardbarret@1152-MBP  ~/Git/SalesforceCLI/Integration/Slack   master ●  ./automated_messages.sh  ✔  1488  10

Can't find virtualenv in path even though its there

↘锁芯ラ 提交于 2021-02-08 07:25:40
问题 I'm trying to set up Django. I have Python 3.6 installed, and I installed virtualenvwrapper using pip3. Here is what my bash profile looks like: # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi export PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.6/bin/virtualenv" export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 export PROJECT

Can't find virtualenv in path even though its there

蓝咒 提交于 2021-02-08 07:25:00
问题 I'm trying to set up Django. I have Python 3.6 installed, and I installed virtualenvwrapper using pip3. Here is what my bash profile looks like: # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi export PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.6/bin/virtualenv" export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 export PROJECT

Properly quote bash alias definition

烈酒焚心 提交于 2021-02-08 06:47:49
问题 I have the following command that I am trying to put into a bash alias. The command by itself works fine, but when I try to alias it, I am getting the following errors: The Command find . -maxdepth 1 -mindepth 1 -type d -exec sh -c 'echo "$(find "{}" -type f | wc -l)" {}' \; | sort -nr The Alias alias csfiles='find . -maxdepth 1 -mindepth 1 -type d -exec sh -c 'echo "$(find "{}" -type f | wc -l)" {}' \; | sort -nr' The Error: -sh: alias 0: not found -sh: alias {} \; | sort nr: not found I

python, read the filename from directory , use the string in bash script

℡╲_俬逩灬. 提交于 2021-02-08 06:44:25
问题 I am writing a bash script (e.g. program.sh ) where I am calling a python code in which a list of files are read from a directory. the python script ( read_files.py ) is as following: import os def files(path): for filename in os.listdir('/home/testfiles'): if os.path.isfile(os.path.join('/home/testfiles', filename)): yield filename for filename in files("."): print (filename) Now I want to keep the string filename and use it in the bash script. e.g. program.sh : #!/bin/bash python read_files

AWK set multiple delimiters for comma and quotes with commas

こ雲淡風輕ζ 提交于 2021-02-08 06:43:33
问题 I have a CSV file where columns are comma separated and columns with textual data that have commas are quoted. Sometimes, within quoted text there also exist quotes to mean things like inches resulting in more quotes. Textual data without embedded commas do not have quotes. For example: A,B,C 1,"hello, how are you",hello 2,car,bike 3,13.3 inch tv,"tv 13.3""" How do i use awk to print the number of columns for each row of which i should get 3 3 3 I thought of using $awk -F'[,"]' but im getting

How to use nslookup in bash to verify is DNS is configured properly?

陌路散爱 提交于 2021-02-08 06:28:10
问题 Mainly I want to detect if DNS is configured properly on a machine by using nslookup . Sadly it seems that nslookup still returns success error codes when it fails to lookup an entry. Also the fact that different queries could return multiple results makes it harder to test it. So I want to write a bash snippet that returns success if the dns entry resolved successfully. I don't care if I get multiple results. Example nslookup -type=srv _ldap._tcp.DOMAIN.COM 回答1: The correct solution would be

How to get the exit status of multiple parallel background processes in bash [duplicate]

◇◆丶佛笑我妖孽 提交于 2021-02-08 06:11:48
问题 This question already has answers here : How to wait in bash for several subprocesses to finish and return exit code !=0 when any subprocess ends with code !=0? (31 answers) Closed 3 years ago . In Bash, I want to call a command multiple times in parallel, while capturing all the processes exit codes. I know how to start and wait for them, but wait will only give me the exit code of the last process exiting. I also need the exit code of the shorter lived processes. Unfortunately I don't have

For loop over sequence of large numbers in Bash [duplicate]

大城市里の小女人 提交于 2021-02-08 06:08:47
问题 This question already has answers here : Bash command line and input limit (3 answers) Closed 2 years ago . In a Bash script I am using a simple for loop, that looks like: for i in $(seq 1 1 500); do echo $i done This for loop works fine. However, when I would like to use a sequence of larger numbers (e.g. 10^8 to 10^12), the loop won't seem to start. for i in $(seq 100000000 1 1000000000000); do echo $i done I cannot imagine, that these numbers are too large to handle. So my question: am I

For loop over sequence of large numbers in Bash [duplicate]

夙愿已清 提交于 2021-02-08 06:05:24
问题 This question already has answers here : Bash command line and input limit (3 answers) Closed 2 years ago . In a Bash script I am using a simple for loop, that looks like: for i in $(seq 1 1 500); do echo $i done This for loop works fine. However, when I would like to use a sequence of larger numbers (e.g. 10^8 to 10^12), the loop won't seem to start. for i in $(seq 100000000 1 1000000000000); do echo $i done I cannot imagine, that these numbers are too large to handle. So my question: am I