logo
down
shadow

How do I use pipes and variable substitution in a shell script (for toggling haproxy active server)?


How do I use pipes and variable substitution in a shell script (for toggling haproxy active server)?

By : user2950416
Date : November 17 2020, 11:55 AM
hop of those help? I have a mildly complicated operation that I want to do with Docker, bash, and socat (though I welcome other solutions) , You don't need so many quotes:
code :
 sudo docker run --rm --volumes-from myhaproxy mytest/socat /bin/bash -c 'echo "set weight server/server-$current_server 1" | socat /var/run/haproxy.sock stdio && echo "set weight server/server-$inactive_server 0" | socat /var/run/haproxy.sock stdio'
 sudo docker run --rm --volumes-from myhaproxy mytest/socat /bin/bash -c "echo set weight server/server-$current_server 1 | socat /var/run/haproxy.sock stdio && echo set weight server/server-$inactive_server 0 | socat /var/run/haproxy.sock stdio"
 sudo docker run --rm --volumes-from myhaproxy mytest/socat /bin/bash -c "other \"set weight server/server-$current_server 1\" | socat /var/run/haproxy.sock stdio && other \"set weight server/server-$inactive_server 0\" | socat /var/run/haproxy.sock stdio"


Share : facebook icon twitter icon
command substitution in shell script with shell variables within the substitution

command substitution in shell script with shell variables within the substitution


By : Patricia Paez Carden
Date : March 29 2020, 07:55 AM
Hope this helps awk to the rescue!
you can replace all with this script, using the values in the sample input
code :
$ awk '{for(i=6;i<=NF;i++) sum+=$i; 
        printf "%s %s %s %.2f\n", $1,$2,$3, sum/(NF-5); 
        sum=0}' file

Important identifier line 39.11
another important identifier 79.67
$ awk '{for(i=6;i<=NF;i++) a[i-5]=$i; 
        asort(a); 
        mid=(NF-4)/2; print mid, a[mid]}' file

5 38
5 29
Variable substitution in Shell script

Variable substitution in Shell script


By : MadreDeDios
Date : March 29 2020, 07:55 AM
around this issue I have declared one variable IS_abc=false, on basis of certain condition I am changing value to IS_abc=true , You can use indirect var reference:
code :
my_arr=('abc' 'pqr' 'xyz')
IS_abc=true

var="IS_${my_arr[0]}"
echo "${!var}"
true
In HAProxy, is it possible to stop routing traffic to a specific server with active sessions by disabling the server?

In HAProxy, is it possible to stop routing traffic to a specific server with active sessions by disabling the server?


By : Fabrício Beltran
Date : March 29 2020, 07:55 AM
it fixes the issue I am trying implement the following setup , Found the answer. Need to add the following directives:
code :
on-marked-down shutdown-sessions
server redis1 127.0.0.1:6379 check on-marked-down shutdown-sessions
server redis2 127.0.0.1:7379 check on-marked-down shutdown-sessions
TFS 2017 - Variable substitution with double backslash in shell script

TFS 2017 - Variable substitution with double backslash in shell script


By : drassi
Date : March 29 2020, 07:55 AM
this one helps. Yes, I solved it!!!
I just put the backslashes inside double quotes
Substitution in shell script

Substitution in shell script


By : Tempo Tom
Date : March 29 2020, 07:55 AM
will be helpful for those in need I like to evaluate the following in linux shell , Use functions.
code :
cmd_6 () { ls; }
cmd_7 () { ls -l; }
ver=6
cmd="cmd_$ver"
"$cmd"
Related Posts Related Posts :
  • Why ordinary user cannot use chgrp/chown
  • Execute a script on startup of SUSE reboot
  • Extracting debugging information from core files
  • linux command to connect to another server using hostname and port number
  • GLib.Settings.changed event not firing
  • What does it mean by code holding semaphore can be preempted
  • Does LD_LIBRARY_PATH really cause inconsistencies?
  • "lsof" shows a file as (deleted) but I can still see it in file system
  • Linux file deleted recovery
  • Exchange columns in bash
  • How to set max file size in Linux CeNTOS to server.log
  • Regular expressions: Search a word and append a new word at the end of the line
  • Compress a set of log files in a folder depending on number of files
  • unexpected behavior of linux malloc
  • relation between init and bash terminal process
  • Matlab VideoReader codec error?
  • How to catch the L3-cache hits and misses by perf tool in Linux
  • Executable Deleting Itself on linux
  • How to change the apache httpd port for serving files
  • Installing Patches in linux
  • Comparative analysis between libkvm on linux and NetBSD
  • How to join multiple txt files into based on column?
  • setting LINK variable in Makefile generated by qmake (5.0)
  • Automake - difficulty with installing version 'automake-1.14.1'
  • How to use Linux Network Namespaces for per processes routing?
  • How can I write a Gruntfile with different shell command behaviour for OS X vs. Linux?
  • Using at command in shell script for scheduling a command
  • Is there a method to figure out the audio channel layout in Linux?
  • Setting environment varilable for daemon / root process
  • string replacement in shell script
  • Add specific column to the end of a CSV file
  • Are there programmable automount/autofs hooks in linux/systemd?
  • Renaming files like 20141207_190822.jpg to "2014-12-07 19.08.22.jpg" in linux or MacOS X
  • undocumented kernel boot parameter?
  • using wget to mirror a website with path and subfolder that have the same name
  • Using awk to find data matching date range in text file
  • Installing xorg-x11-devel package in SLES 11 SP2
  • Setting result of find to variable, which has variables within it
  • Maximum/Minimum physical address - Linux kernel
  • Freepbx custom context outbound route
  • memcpy implementation in linux kernel
  • How to reverse a list of words in a shell string?
  • Concatenate and pass as parameter in bash
  • Add user to Docker container
  • How to add a content in a file in linux without opening the file using vi or cat command
  • Which SVN subversion can I use on linux, Mac, Windows?
  • Work with ZIP archive at Bash
  • bash script not running as expected from cron vs. shell.
  • Compare one field, Remove duplicate if value of another field is greater
  • sudoers NOPASSWD: sudo: no tty present and no askpass program specified
  • Linux/Unix Find Command
  • Not able to copy data in hdfs with hdfs dfs commands
  • Linux : Remove/Delete .txt files ending with exactly five digits
  • ARM assembly "retne" instruction
  • Migrate from LXC to LXD
  • sbt on linux not accepting -jvm-debug 5005
  • Supervisord events only sent to one eventlistener in pool
  • Finding all .c files in linux using grep
  • Extract part of a file name in bash
  • Bash Script to Comment/uncomment lines in file
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org