Bash Oiutput Correction – Code Revision Stack Exchange

#! / bin / bash

start () {
actual printf:% s  n & # 39; "$ (curl -s ifconfig.co)"
set - /etc/openvpn/ovpn_tcp/*.nordvpn.com.tcp.ovpn
shift $ ((RANDOM% $ #))
screen -S vpn -dm openvpn "$ 1" # connect
sleep 5 # wait for the connection
printf VPN IP:% s  n & # 39; "$ (curl -s ifconfig.co)"
}
Stop () {
-S vpn -X screen exit
pkill -f ovpn
}
status(){
printf current IP:% s  n & # 39; "$ (curl -s ifconfig.co)"
}

case "$ 1" in
beginning)
if screen -ls | grep -w vpn &> / dev / null; then
echo "VPN already connected";
status
other
beginning
Fi
;;
stop)
stop
;;
*)
status
;;
esac

The previous hit script gives the following answer in case vpn stop typed.

series of vpn stop if there is active vpn link:

[root@A ~]# vpn stop
Completed

series of vpn stop if there is no activity vpn link:

[root@A ~]# vpn stop
No screen session found.
Completed

What I am trying to achieve is:

series of vpn stop if there is active vpn link:

[root@A ~]# vpn stop
VPN connection closed successfully 

series of vpn stop if there is no activity vpn link:

[root@A ~]# vpn stop
There is no active VPN connection to stop it.

bash – Removing Ubuntu Privacy Violation Features

I want to remove all Ubuntu tracking features in a single line (or a few lines) of Bash script. Is it enough or am I missing something:

$ sudo apt-get remove zeitgeist zeitgeist-core zeitgeist-datahub python-zeitgeist rhythmbox-plugin-zeitgeist geoclue geoclue-ubuntu-geoip geoip-database

The target is Ubuntu LTS.

Definition of the protection of privacy

  1. trackers
  2. All that provides my geolocation to a website
  3. Any follow up of the back-end advertising, etc.

Basically, I'm also open to suggestions and do not consider my code as a quick and easy solution.

How to run a bash shell script from a html button click?

If I have a simple bash script

#! / bin / bash
tap ./test.txt

that I want to be activated at the push of a button on a simple html page, how to proceed?

html looking for something like this (but I know it's wrong)

Thank you for any help!

Unable to store multiple arguments with read -p in a macOS terminal with bash

The variable IFS is used by various commands. The safest thing to do is to save the value and then restore it when done. Here is an example.

declare "IFS_BACKUP = $ IFS"
IFS = $ & # 39;  t  n & # 39;
read -p "Enter your order:" cmd arg1 arg2
IFS = "$ IFS_BACKUP"
echo "$ cmd"
echo "$ arg1"
echo "$ arg2"

The documentation command man bash defines IFS as following:

            IFS Internal field separator used for word division
after expanding and splitting the lines into words at reading
integrated control. The default value is ``& # 39; & # 39;

linux – Bash creates a user and assigns an existing folder as the home page

name = $ 1
folder = $ 2

useradd $ name
echo "user $ name successfully added!"
echo $ name: "123" | chpasswd
echo "Password for the user $ i changed successfully"

usermod -d ~ / Projects / $ folder -m $ name
echo "Home set for user"

sudo chown -R $ name: $ name ~ / Projects / $ folder
sudo chmod -R 755 ~ / Projects / $ folder

The user is added with a password and the personal folder configuration works perfectly. The problem is when SSH on the server with the newly created account and I get this error Unable to connect to the root directory / root / Projects / project12: Permission denied. I have tried many versions of chmod.

How can I fix the error in the best way? Please do not bother the password, it's just for test purposes.

linux – Bash script to check LDAP profile

I have a script below bash to check the LDAP profiles (that is, the IP address) that works well, but I would appreciate any improvements.

#! / bin / bash
# s = 1; s * = 2; s * = 3 here using math, the value s will only be divisible by 6 if factors 2 and 3 are present, here several occurrences will not change the condition but only the last values ‚Äč‚Äčencountered will be used.
# s &&! (s% 6) checks the divisibility by 6 and if the value is initialized in the "dn" check.
# s = 0 reset the value after printing, so that printing will be suspended until the next group.
# sep you want the triples to be separated by an empty line, we do not want to add after each group, because it will leave a blank line at the end or in the same way at the beginning. An alternative is to use a late initialized variable (after first use). So, there will be no empty line at the beginning or the end, but between the groups.
# mapfile is the bash build function that can be used with BASH Version> = 4.0 from

set -f # to prevent file name expansion

mapfile -t PLIST << (ldapsearch -h my-server-ldap -x -LLL -b "or = profile, o = rocksg.com" "cn = *" | awk = / ^ dn / {s = 1; dn = $ 0} / ^ preferredServerList / {s * = 2; ps = $ 0} / ^ defaultServerList / {s * = 3; ds = $ 0} s &&! (S% 6) {print sep dn ORS ps ORS ds; sep = ORS; s = 0} & # 39; | awk / preferredServerList / {print $ 2, $ 3, $ 4} & # 39;)

mapfile -t DLIST << (ldapsearch -h my-server-ldap -x -LLL -b "or = profile, o = rocksg.com" "cn = *" | awk | / ^ dn / {s = 1; dn = $ 0} / ^ preferredServerList / {s * = 2; ps = $ 0} / ^ defaultServerList / {s * = 3; ds = $ 0} s &&! (S% 6) {print sep dn ORS ps ORS ds; sep = ORS; s = 0} & # 39; | awk / defaultServerList / {print $ 2, $ 3, $ 4} & # 39;)

mapfile -t LLIST << (ldapsearch -h my-server-ldap -x -LLL -b "or = profile, o = rocksg.com" "cn = *" | awk / / dn / {s = 1; dn = $ 0} / ^ preferredServerList / {s * = 2; ps = $ 0} / ^ defaultServerList / {s * = 3; ds = $ 0} s &&! (S% 6) {print sep dn ORS ps ORS ds; sep = ORS; s = 0} & # 39; | awk # / dn / {print $ 2} & # 39; | cut -d "," -f1 | cut -d "=" - f2)

count_x = $ {# PLIST[@]}
count_y = $ {# DLIST[@]}
count_l = $ {# LLIST[@]}

# Find out which one is bigger, assuming it's a possibility
if [[ $count_x -lt $count_y ]]then
count = $ count_y
other
count = $ {count_x}
Fi

Result of the executed script:

$ ./ldaphostprofile.sh

=============================================== === ============================================ ===
PreferredList IP's: DefaultServerList IP's: Location
=============================================== === ============================================ ===
192.168.56.7: 192.168.55.11: AUSTIN
192.168.56.8: 192.168.55.11: CANADA

------------------ truncated output ------------------------------ ------

However, if I do a little grep Location so it does not show the header and it's obvious because i have no logic in place ..

$ ./ldaphostprofile.sh | egrep "AUSTIN | CANADA"
192.168.56.7: 192.168.55.11: AUSTIN
192.168.56.8: 192.168.55.11: CANADA

Desired: (to obtain header information when searching)

$ ./ldaphostprofile.sh | egrep "AUSTIN | CANADA"
=============================================== === ============================================ ===
PreferredList IP's: DefaultServerList IP's: Location
=============================================== === ============================================ ===
192.168.56.7: 192.168.55.11: AUSTIN
192.168.56.8: 192.168.55.11: CANADA

bash – How to cut a data file with columns separated by spaces

I have a data file with 2 columns

1.0000 9.9398383
1.4399 8.0000000
2.5688 7.9393838

1.0000 4.0000000
1.4399 9.0094949
2.5688 3.9932323

1.0000 8.9393993
1.4399 7.3838473
1,5688 2,8337738

I want to create a different file with this data separated by a blank line, but I do not know how to cut the file after or before the blank line, help me please.

bash – Error while running 'msfconsole & # 39; and of & # 39; bundle install & # 39;

I get the error below when running the 'install bundle' command.

I run msfconsole & # 39; and receive this:

            $ msfconsole waiting for the server to stop .... 2019-05-08 11: 04: 55.057 AEST [14797] LOG: prompt stop request received
2019-05-08 11: 04: 55.058 AEST [14797] LOG: abandoning active transactions
2019-05-08 11: 04: 55.059 AEST [14797] LOG: The "Logical Replication Launcher" of the Background Agent (PID 14807) was left with exit code 1
2019-05-08 11: 04: 55.060 AEST [14802] LOG: closing
2019-05-08 11: 04: 55.091 AEST [14797] LOG: the database system is stopped
completed
stopped server
waiting for the server to start .... 2019-05-08 11: 04: 55.204 AEST [17104] LOG: listen on the IPv4 address "127.0.0.1", port 5432
2019-05-08 11: 04: 55.204 AEST [17104] LOG: listen on the Unix socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432"
2019-05-08 11: 04: 55.221 AEST [17108] LOG: database system was stopped at 2019-05-08 11:04:55 AEST
2019-05-08 11: 04: 55.226 AEST [17104] LOG: the database system is ready to accept connections
completed
server started

Can not find nokogiri-1.10.1 in any of the sources
Run `bundle install` to install the missing gems.

Then, when I run 'install bundle & # 39; and that I receive this:

$ bundle install Gemfile does not specify any dependencies
Complete bundle! 0 Gemfile dependencies, 1 gem now installed.
Use bundle information [gemname]`to see where a jewel provided is installed.
$

I've also tried to install "nokogiri". but it made a mistake:

                $ install the native extensions of the nokogiri building. It could take a moment ...
ERROR: Error while installing nokogiri:
ERROR: Can not create a native gem extension.

Current directory: /data/data/com.termux/files/usr/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.3/ext/nokogiri
/data/data/com.termux/files/usr/bin/ruby -I /data/data/com.termux/files/usr/lib/ruby/site_ruby/2.6.0 -r ./siteconf20190508-18809-1xe5kij. rb extconf.rb
check if the C compiler accepts ... yes
Build nokogiri using bundled libraries.
Using mini_portile version 2.4.0
The static link is disabled.
gzdopen () check in -lz ... no
zlib is missing; needed for building libxml2
*** extconf.rb failed ***
Could not create the Makefile for any reason, probably lack of necessary resources.
libraries and / or headers. See the mkmf.log file for more details. You can
need configuration options.
To see why this extension could not be compiled, please consult the file mkmf.log which you can find here:

/data/data/com.termux/files/usr/lib/ruby/gems/2.6.0/extensions/aarch64-linux/2.6.0/nokogiri-1.10.3/mkmf.log

extconf failed, exit code 1

The Gem files will remain installed in /data/data/com.termux/files/usr/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.3 for inspection.
Results found in /data/data/com.termux/files/usr/lib/ruby/gems/2.6.0/extensions/aarch64-linux/2.6.0/nokogiri-1.10.3/gem_make.out
$

Why does this happen and how can I solve the problem?

Thanks in advance

bash – How to execute commands in the terminal from a script

I'm trying to write a handy script for managing python environments on my system. As a part of that, I add the scripting aliasing utility of environments, so that I do not have to provide the path of Full access. An example:

pyenv -c new_environment # Create a new environment
pyenv new_environment # Source environment
disable # ...
pyenv -d new_environment # Delete the environment

The problem I have is that I can not get the terminal activation script from the pyenv script. I've tried a lot of things as shown below, but no luck.

source $ environment_path / bin / activate
bash $ environment_path / bin / activate
exec "source $ environment_path / bin / activate"
exec "$ environment_path / bin / activate"
$ environment_path / bin / activate
eval "source $ environment_path / bin / activate"

How can I run a line from a script (source path in this case) in the terminal, so that the effects of the line are related to the terminal?

bash – fc command somehow mapped to iv

I would like to use the fc command 1. However, when I type fc at bash I get

The command & # 39; iv & # 39; iv & # 39; can not be found, but can be installed with:

sudo apt install openimageio-tools

It's weird because I did not even type it iv. In addition, the suggested package seems to be an image processing library that is far from what I want.

What's going on here and how can I use fc?