shell

Iterating through PL/SQL result in SHELL

主宰稳场 提交于 2021-02-08 10:21:06
问题 I want to iterate over PL/SQL rows in SHELL script and for each row I want to execute some code using current row. At this point I got: VALUE='sqlplus -s /nolog <<EOF CONNECT ${CONNECT} select smth from table; / EXIT EOF' for i in "${VALUE[@]}" do ##some code using "i" variable done At this point for 5 rows code executes only once. It appears it doesn't iterate at all. Any ideas how can I fix that? 回答1: You can iterate your resultset as follows: SQL> select car_model from available_models 2

Bash Script - fswatch trigger bash function

余生长醉 提交于 2021-02-08 09:47:38
问题 I have a bash script where I want to trigger a method every time the filesystem is changed: #!/bin/bash function run { echo Do some magic // Do some magic } run fswatch . src | 'run' In this case I am watching the src folder. When I trigger the script via ./automater.sh the script executes the run function the first time correctly and when I then change some file, the script simply exits... 回答1: BUT then it runs in a loop.... , I also hit this, because after your ./automater.sh execution,

jq: Cannot index array with string “id”

爱⌒轻易说出口 提交于 2021-02-08 09:17:37
问题 My backup.json looks like this: { "andres": [ [ { "id": 1, "email": "password", "username": test1, "password": "email@email.com", "name": "Dummy Account", "address": "123 st road",, "ip_address": "0.0.0.0", "phone": "123-123-1234", }, { "id": 2, "email": "email2@email.com", "username": test2, "password": "password", "name": "Dummy Account", "address": "123 st road",, "ip_address": "0.0.0.0", "phone": "123-123-1234" } ], ] } I'm using the command: jq -r '.andres[] | .id, .email, .username,

How to strip ANSI escape codes from AIX topas command result in C#

天大地大妈咪最大 提交于 2021-02-08 08:45:19
问题 I'm trying to capture AIX real-time information like CPU, memory, IO load with a C# console application because I would like to show that information in a third part custom dashboard. After running the command topas, I need to capture periodically the whole following text: I tried to capture it with the following code that I have found out in some forum: using Renci.SshNet; using System; using System.IO; using System.Threading; namespace SSH_check_commands { public class MyAsyncInfo { public

Efficient way of sending the same data to multiple dynamic processes

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 08:43:19
问题 I have a stream of line-buffered data, and many readers from other processes The readers need to attach to the system dynamically, they are not known to the process writing the stream First i tried to read every line and simply send them to a lot of pipes #writer command | while read -r line; do printf '%s\n' "$line" | tee listeners/* done #reader mkfifo listeners/1 cat listeners/1 But that's consume a lot of CPU So i though about writing to a file and cleaning it repeatedly #writer command >

Pipe a command and redirect the output with command

依然范特西╮ 提交于 2021-02-08 08:37:16
问题 Here is my code: package main import ( "fmt" "os" "os/exec" "strconv" "time" ) func main() { year, month, day := time.Now().Date() monthI := int(month) fmt.Println("toto") date := strconv.Itoa(year)+"_"+strconv.Itoa(monthI)+"_"+strconv.Itoa(day) nameSnapshot := "storedb@backup_"+date args := []string{"snapshot",nameSnapshot} cmd := exec.Command("zfs", args...) err := cmd.Run() if err != nil { os.Stderr.WriteString(err.Error()) } args = []string{"send",nameSnapshot,"|","gzip",">","backup_"

While loop in bash to read a file skips first 2 characters of THIRD Line

早过忘川 提交于 2021-02-08 08:16:24
问题 #bin/bash INPUT_DIR="$1" INPUT_VIDEO="$2" OUTPUT_PATH="$3" SOURCE="$4" DATE="$5" INPUT="$INPUT_DIR/sorted_result.txt" COUNT=1 initial=00:00:00 while IFS= read -r line; do OUT_DIR=$OUTPUT_PATH/$COUNT mkdir "$OUT_DIR" ffmpeg -nostdin -i $INPUT_VIDEO -vcodec h264 -vf fps=25 -ss $initial -to $line $OUT_DIR/$COUNT.avi ffmpeg -i $OUT_DIR/$COUNT.avi -acodec pcm_s16le -ar 16000 -ac 1 $OUT_DIR/$COUNT.wav python3.6 /home/Video_Audio_Chunks_1.py $OUT_DIR/$COUNT.wav python /home/transcribe.py --decoder

While loop in bash to read a file skips first 2 characters of THIRD Line

荒凉一梦 提交于 2021-02-08 08:14:11
问题 #bin/bash INPUT_DIR="$1" INPUT_VIDEO="$2" OUTPUT_PATH="$3" SOURCE="$4" DATE="$5" INPUT="$INPUT_DIR/sorted_result.txt" COUNT=1 initial=00:00:00 while IFS= read -r line; do OUT_DIR=$OUTPUT_PATH/$COUNT mkdir "$OUT_DIR" ffmpeg -nostdin -i $INPUT_VIDEO -vcodec h264 -vf fps=25 -ss $initial -to $line $OUT_DIR/$COUNT.avi ffmpeg -i $OUT_DIR/$COUNT.avi -acodec pcm_s16le -ar 16000 -ac 1 $OUT_DIR/$COUNT.wav python3.6 /home/Video_Audio_Chunks_1.py $OUT_DIR/$COUNT.wav python /home/transcribe.py --decoder

While loop in bash to read a file skips first 2 characters of THIRD Line

﹥>﹥吖頭↗ 提交于 2021-02-08 08:14:09
问题 #bin/bash INPUT_DIR="$1" INPUT_VIDEO="$2" OUTPUT_PATH="$3" SOURCE="$4" DATE="$5" INPUT="$INPUT_DIR/sorted_result.txt" COUNT=1 initial=00:00:00 while IFS= read -r line; do OUT_DIR=$OUTPUT_PATH/$COUNT mkdir "$OUT_DIR" ffmpeg -nostdin -i $INPUT_VIDEO -vcodec h264 -vf fps=25 -ss $initial -to $line $OUT_DIR/$COUNT.avi ffmpeg -i $OUT_DIR/$COUNT.avi -acodec pcm_s16le -ar 16000 -ac 1 $OUT_DIR/$COUNT.wav python3.6 /home/Video_Audio_Chunks_1.py $OUT_DIR/$COUNT.wav python /home/transcribe.py --decoder

How to add confirm in shell script in sftp mode [duplicate]

天涯浪子 提交于 2021-02-08 07:45:23
问题 This question already has answers here : How can I force ssh to accept a new host fingerprint from the command line? (6 answers) Closed 1 year ago . I have a shell script which is performing some renaming and archiving steps. I have added sftp commands to copy multiple files. But when i try to login to the remote machine thru putty it asks for confirmation like Are you sure you want to continue connecting (yes/no)? . I need to enter yes. but since this is being done thru the script am not