shell

How to call snowsql client from python

房东的猫 提交于 2021-01-29 06:05:20
问题 I'm calling snowsql client from shell script. I'm importing properties file by doing source. And invoking snowsql client. How can I do the same in Python? Any help would be highly appreciated. Shell script to call snowsql client: source /opt/data/airflow/config/cyrus_de/snowflake_config.txt sudo /home/user/snowsql -c $connection --config=/home/user/.snowsql/config -w $warehouse --variable database_name=$dbname --variable stage=$stagename --variable env=$env -o exit_on_error=true -o variable

How can I extract only the name field from json by using gcloud command?

ぃ、小莉子 提交于 2021-01-29 06:04:51
问题 I am new to gcp and linux. I am trying to get the name from the json format using the gcloud command. Below is the command and output: gcloud firestore indexes composite list --format=json Output: [ { "fields": [ { "fieldPath": "is_active", "order": "ASCENDING" }, { "fieldPath": "created_at", "order": "DESCENDING" }, { "fieldPath": "__name__", "order": "ASCENDING" } ], "name": "projects/emc-ema-simcs-d-286404/databases/(default)/collectionGroups/customer/indexes/CICAgNjbhowK", "queryScope":

How can I fix my expect script for scp download?

左心房为你撑大大i 提交于 2021-01-29 05:42:55
问题 I am trying to use expect to bypass the password authentication process for a remote server I'm using, so I can download a series of files in bulk, each of which is stored in a different folder. The reason for using expect is the remote files are stored in separate folders, and the server I'm accessing won't allow me ssh key access. At present I am struggling to download a single file using expect, never mind numerous ones at once. Below is my simple script: #!/bin/bash #connect to the server

Run script when eth0 UP

天大地大妈咪最大 提交于 2021-01-29 05:00:46
问题 I need to run a script after the start eth0 interface in Centos 6.8 When I do it with ppp0 I put scripts here: /etc/ppp/ip-up.local and it works. How to do the same with eth0 ? I tried to put scripts in difference files, checking permissions, but does not work. Files that I tried to put scripts: **/etc/sysconfig/network-scripts/ip-up.local /etc/sysconfig/network-scripts/ifup-local /sbin/ifup-pre-local /sbin/ifup-local /sbin/ip-up.local** 回答1: Using NetworkManager , we can create a file /etc

Why does field splitting not occur after parameter expansion in an assignment statement in shell?

為{幸葍}努か 提交于 2021-01-29 04:00:48
问题 Consider the following two assignments. $ a="foo bar" $ b=$a $ b=foo bar bash: bar: command not found Why does the second assignment work fine? How is the second command any different from the third command? I was hoping the second assignment to fail because b=$a would expand to b=foo bar Since $a is not within double-quotes, foo bar is not quoted, therefore field-splitting should occur (as per my understanding) which would result in b=foo to be considered an assignment and bar to be a

Use substituted string as a command in shell script

帅比萌擦擦* 提交于 2021-01-29 03:51:25
问题 Given the variables listed below: echo ${userupper}_PYTHON # YTU_PYTHON echo $YTU_PYTHON # /home/ytu/anaconda3/bin/python echo $path # foo.py Now I'd like to execute /home/ytu/anaconda3/bin/python foo.py with userupper and path . I tried $(${userupper}_PYTHON) $path but it ends up with error messages including: YTU_PYTHON: not found foo.py: not found It seems like it takes $(${userupper}_PYTHON) as bare YTU_PYTHON rather than expected $YTU_PYTHON . How should I do to make it right? Edits: The

Add black video to video with sound

烂漫一生 提交于 2021-01-29 03:39:52
问题 I'm trying to insert 13 seconds of black video at the start of a video that has sound using ffmpeg like so: ffmpeg -f lavfi -i "color=c=black:s=720x406:r=25:sar=1/1" -i input.mp4 -filter_complex \ "[0:v] trim=end=13,setpts=PTS-STARTPTS [blackstart]; \ [blackstart] [1:v] concat=n=2:v=1:a=0[out]" \ -map "[out]" -c:a copy output.mp4 However the sound is not being maintained. What am I doing incorrectly? -c:a copy does not seem to work should I be using a [1:a] somewhere? garrett-retina:~ garrett

Can I stop later parts of a pipeline from running if an earlier part failed?

岁酱吖の 提交于 2021-01-29 03:01:03
问题 I have a piped command such as: set -euxo pipefail echo 'hello' | foo | touch example.sh This is the output: $ set -euxo pipefail $ echo hello $ foo $ touch example.sh pipefail.sh: line 4: foo: command not found I thought set -e would cause the script to exit however. But even though foo is unrecognized, the script is still executing the touch command. How do I get it to exit if foo fails? 回答1: You can't really think of a pipeline of having "earlier" or "later" parts, except insofar as data

Adding value to global variable in a subshell is not working

∥☆過路亽.° 提交于 2021-01-29 02:45:57
问题 I am trying to get the total disk usage of my machine. Below is the script code: #!/bin/sh totalUsage=0 diskUse(){ df -H | grep -vE '^Filesystem|cdrom' | awk '{ print $5 " " $1 }' | while read output; do diskUsage=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) totalUsage=$((totalUsage+diskUsage)) done } diskUse echo $totalUsage While totalUsage is a global variable, I have tried to sum the individual disk usage to totalUsage in the line: totalUsage=$((totalUsage+diskUsage)) An echo of

Adding value to global variable in a subshell is not working

爷,独闯天下 提交于 2021-01-29 02:44:05
问题 I am trying to get the total disk usage of my machine. Below is the script code: #!/bin/sh totalUsage=0 diskUse(){ df -H | grep -vE '^Filesystem|cdrom' | awk '{ print $5 " " $1 }' | while read output; do diskUsage=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) totalUsage=$((totalUsage+diskUsage)) done } diskUse echo $totalUsage While totalUsage is a global variable, I have tried to sum the individual disk usage to totalUsage in the line: totalUsage=$((totalUsage+diskUsage)) An echo of