You do not need to forward agent if you use Proxy commands. Proxy command mean main ssh tunnel carry port forward to destination host and the connection is established between your host and destination host, but agent forwarding is when ssh connections are chained one ...
When you just want to get whatever comes between the "mailto: and the ", then this would do the trick:
grep -oP '(?<="mailto:)[^"]+(?=")'
It uses positive lookbehind and positive lookahead which is supported by the Perl regex syntax (-P flag).
If you need additional validation of the address, you might want to look into ...
cat server-list.txt not more server-list.txt (more is paginated)
If you're scripting this them it's probably easier to use a keyless password rather than going through sshpass -p password
Use $() instead of ` eg for server in $(cat server-list.txt)
Finally Some echo statements in your script
P.s. This question would be better over at SuperUser
The variable '$?' stores the result of the previous command.
0 = success
1-127 = documented error
(-128)-(-1) = OS killed the program with some signal
sshpass -p password ssh root@$server /sbin/reboot
if [ $? -eq 0 ]; then
echo "$server - Successfully rebooted"
echo "$server - Failed to reboot"
Another solution is just simply add shopt -s lastpipe before the while loop.
I say, if the trouble comes cause the while is in the last segment of the pipeline, and in Bash all the commands in a pipeline exeutes in a subshell in a separated process, then, using the lastpipe will execute the last command in the pipeline in the foreground.
please use the -d option of xargs
--delimiter=delim, -d delim
Input items are terminated by the specified character. The specified delimiter may be a single character, a C-style character escape such as \n, or an octal or hexadecimal escape code. Octal and
hexadecimal escape codes are understood as for the printf command. Multibyte characters are ...
I recently had the same problem. IMHO, trying to write a shell script to do it is painful, and it is much easier to write some reusable logic using a higher-level language with builtins like sets, dictionaries, etc. The general idea is to take configuration indicating how many files of each period you want to keep, and then decide for each file if it should ...
Use ts command from moreutils (apt get moreutils).
$ ls -1 | ts
Oct 12 20:09:27 ts-out.v37mPS
Oct 12 20:09:27 ts-out.vavMYs
Oct 12 20:09:27 ts-out.wd9G1Y
Oct 12 20:09:27 ts-out.ym8aN0
Oct 12 20:09:27 ts-out.zCzWhY
okay. the sed option works. i'd mistakenly confused my slashes, but they are correct and works perfectly. i'll leave this up in case anyone else has a similar questions, but if admins want to turf it, so be it.
php -f myFile.php | sed 's/<br>/\n\r/gp'
Butterfly Backup is nothing more than an rsync wrapper. Use the --link-dest flag to create hard links on files. Most likely, the file system where you are placing your catalog does not support hard links. I have a Butterfly Backup server with its catalog in an ext4 file system, and I have no problem.
I have noticed that using xargs with printf works well and is fast.
ls | xargs -d '\n' -l printf '%s: %s' "$timestamp" 1>&2
I write to stderr just not to pollute the stdout.
I have made a logging utility written in bash that I use in my bash scripts:
It has more ...
Generally i would avoid to execute root privilege commands with webservers/php-fpm. So think about, if you really need it. To run this kind of job successfully with your already present scripts, you need to add the user under which your webserver runs (generally www-data) to your sudoers file and allow it to run your the command with sudo without password ...
So the problem here is that SELinux is not allowing Nagios to do a variety of things which, presumably, you actually want it to do (such as running ssh). It's impossible for the distribution to guess at all the things you might need Nagios to do, so while the SELinux policy allows most things related to monitoring, it isn't allowing these things.
You can ...
I was facing a similar situation where I had to delete Docker Container Logs with ".log" extension using a command or a shell script (it was scenario-specific)
Here's the script
#SHELL SCRIPT TO DELETE THE CONTENT OF THE DOCKER CONTAINER LOG FILES
#While loop to read log file name
while IFS= read -d $'\...
Your script specifies set -e, which causes the shell to exit if any command in the script returns an error. If you omit this, then by default the script will continue if any command returns an error.
If you wish to keep set -e and only continue if specific commands return an error, you can make the script ignore the errors from a command by using the ...