New answers tagged

0

Just add the router and transport like this: begin routers whitelister: driver = accept domain = !+local_domains condition = ${if inlist{$sender_address_domain}{+local_domains}} transport = whlist and transport: begin transports whlist: driver = pipe command = spfbl superwhite add "$address_data > $sender_address_data"


2

Assuming you want to overwrite service-user's authorized_keys file with a completely new version, you could do something like this: cat master_authorized_keys | ssh -t user@target \ "sudo -u service-user tee ~/.ssh/authorized_keys >/dev/null" I don't know if the -t there is really necessary, but maybe it is in your environment.


2

All of the pagefile parameters are stored in the registry. Have your script manipulate the values in the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management For instance, the PagingFiles entry is a multi-valued string, with each different paging file on a separate line. The numbers following the filename ...


3

Perl is probably installed, so you can do timestamp=$( some process ) # timestamp=201607130319 perl -se ' use Time::Local; if ($ts =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)$/) { $time = timelocal(0,$5,$4,$3,$2-1,$1-1900); $now = time; if (abs( $time - $now ) > 600) { print "more than 10 minutes\n"; } }...


2

You have already found that your problem is the interaction between set -e and the grep that did not match anything. You can tack on || true to avoid that, but see below. Instead of counting the lines in the file, you could simply test if there is anything at all in the file: if [ -s "TABLE_CHECKS" ] ; then NEW_TABLE_CHECKS=table_checks-`date +%Y-%m-%...


2

Terminate your awk statement and always use proper quoting when using bash. Finally, "[" as test is for the Bourne Shell sh; use "[[" when writing Bourne-Again Shell (bash) scripts. Grep expressions may not work the same way on all systems. I've tried to make yours more generic. #!/bin/bash -x # don't set flags unless you know you need 'em. # # Routine ...


0

You're trying to compare array to init value which is odd. You should print $load2 variable and see what contains.


0

You should use a proper nginx logrotate script on this matter. Here is an example: "/var/log/nginx/*.log" { daily rotate 7 size 100M dateext dateformat -%Y%m%d-%s compress delaycompress missingok notifempty create 0640 www-data adm sharedscripts prerotate ...


0

Try to add this before your cron job. SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin It will show to cron user where executable directories are.


0

You can try this: ssh -q -o StrictHostKeyChecking=no user@host "python -c python-script.py"


3

I just did a tail -f <nginx-access.log> | grep <ip> and as expected new lines showed up regularly. What happens when you try? Could it be hat your grep buffers (I think i've seen that), in that case it might help to add --line-buffered to the grep.


3

This seems to be working: A=$(echo "echo a") && bash -c "paste <(awk -v var=\"$A\" 'BEGIN { printf \"%s\", var }') <(echo 'BBBB')" But, I beg you, don't ever write anything like this. Its just plain gross, it makes people's eyes bleed. Please, use a real programming language like Ruby/Python/Perl if your shell scripts are becoming more ...


0

Try to call tar with the full path. On my system e.g. it's /bin/tar. You can find out with which tar.


7

The problem is that you've put the tilde inside double quotes. When you do this, it is not expanded to the path of your home directory. Consider: MacBook-Pro:~ error$ cat x.sh #!/bin/sh echo ~ echo "~" ls ~ ls "~" MacBook-Pro:~ error$ ./x.sh /Users/error ~ Calibre Library Downloads Music bin Desktop Library Pictures synergy Documents ...


0

When executing the mysql binary from the command line, the -p option, unless given an argument, causes mysql to wait for STDIN (e.g. the user typing the password and hitting enter). You can either execute: cat /root/queries.sql | mysql -u root -p or mysql -u root -p'myPasswordHere' < /root/queries.sql


1

From what I can determine the format of 0x????0004 communicates some additional information. Bit 2 indicates that the BAR is a 1=64-bit, 0=32-bit address, bit 3 indicates that memory region is 1=prefetchable, 0=non-prefetchable.


0

In bash 4.3 it seems you no longer need to use single quotes or set +H: $ bash --version GNU bash, version 4.3.46(1)-release (x86_64-unknown-linux-gnu) [...] $ echo "Reboot your instance!" Reboot your instance!


2

Starting with ssh 7.3 (which is the next upcoming release as I'm writing this), an Include directive is available. Include: Include the specified configuration file(s). Multiple path names may be specified and each pathname may contain glob wildcards and shell-like "~" references to user home directories. Files without absolute paths are assumed to ...


6

No, as far as I know not as bash maintains history in memory and only writes or appends new history items when the shell exits. When you "press the power button" (or run shutdown -f) obviously the shell does not exit gracefully and you lose any new history from that session as that exists only in memory. Previous history items from other sessions of course ...


0

I see no reason to use cpio for any reason other than ripping opened RPM files, via disrpm or rpm2cpio, but there may be corner cases in which cpio is preferable to tar. History and popularity Both tar and cpio are competing archive formats that were introduced in Version 7 Unix in 1979 and then included in POSIX.1-1988, though only tar remained in the ...


0

%(percent) means a new line in cron! So you either have to escape it like this foo=a\%2Bb or put your command in a bash file and run that file in crontab.


1

You could try using awk. If the lines are all prepended by 4 fields then ...| awk '{$1=$2=$3=$4=""; print $0}' but you may need to explicitly flush the output ...| awk '{$1=$2=$3=$4=""; print $0; fflush() }' This basically nulls the first 4 fields. Note that if you then wanted to print just certain fields the first field is still $5, but then I ...


4

You can try using cut to cut out the columns you are interested in. tail -f whatever | cut -d ' ' -f 3- [PROD] - INFO: GET 200 - 5ms [PROD] - INFO: POST 200 - 7ms This -d sets a space as the field delimiter, and -f specifies to display only the third and subsequent fields. Specifying fields can get more complex, too. Suppose you only really want to get ...


0

A common reason for things that don't work in cron, but do work in a shell session is a difference of environment. Compare the output of the env when run from cron versus the shell. Recall that a shell launched from cron is non-interactive, which could result in differences in how your init scripts provision your environment.


3

Assuming you are using the bash shell, take a look at pushd and popd. These are two very unsung commands that are helpful in cases like this. pushd pushes the current working directory onto a stack and then does a cd to the directory you specify. popd will then pop the top directory from that stack and cd to it. Using these your alias would be: alias ...


0

It works for me */5 * * * * screen -dmS ftp-getter /bin/bash /home/user/ftp-getter.sh >> /var/log/ftp-getter.log 2>&1


0

To pass environment variables it may be needed to change the entries for AcceptEnv in sshd_config(5) and SendEnv in ssh_config(5).


1

My original answer ssh VD_PASSWORD="$VD_PASSWORD" ... was wrong because it did not take into account the heredoc and it placed the setting of the environment variable in the wrong place. Even if you put the environment variable in the correct place ssh ... user@remote VD_PASSWORD="$VD_PASSWORD" <<'EOSSH' ... It does not work because of the ...


2

It seems that you want the exit value from the remote script ( $?) and not stdout (the scripts output as per your title) The ssh man page says this ssh exits with the exit status of the remote command or with 255 if an error occurred. So if your script is working correctly it will return 100. If it's not then there are a few possibilities command ...


3

You have to add route to 123.4.5.6 trought your ISP gate. For example: route add -host 123.4.5.6 gw 192.168.0.1 According your Linux distribution put this rule for routing in appropriate config file.


0

If you don't want or can't stop sudo from asking you the password, one simple trick is to read it locally and store it in a local variable: read -p 'Password: ' -s password ssh -t user@1.2.3.4 <<EOF echo "$password" | sudo -S whoami EOF


3

/etc/environment doesn't perform variable expansion. Thus, your PATH is now literally {JAVA_HOME}/bin:{JRE_HOME}/bin:{M2}:{PATH}, which won't work of course. If you use bash only, you might want to look into setting $BASH_ENV in /etc/environment like so: BASH_ENV=/etc/non-inter-test where /etc/non-inter-test is then read and executed by non-interactive ...



Top 50 recent answers are included