Tag Info

New answers tagged

1

Since you don't want to edit the script: for f in $(ls -I "*.sh"); do ./permissions_setup.sh $f; done;


0

Entries like "tds version" and "client charset" are not supported by the ODBC lens since they contain spaces. As you have seen, you can't use IniFile.lns, since this only contains primitives. But you may look for another Ini-based lens. The following would be a good start point: grep IniFile /usr/share/augeas/lenses/dist/* | grep --perl-regexp ...


1

You echoed java pid inside /opt/app/scripts/start script which is true but again echoed pid of su command inside the init script. I think you should change init script like this: start() { if [ "$USER_NAME" != "$RUN_USER" ]; then PID=$(su $RUN_USER -c "$START_SCRIPT $ARGS") else PID=`$START_SCRIPT $ARGS` fi }


1

service start tomee is run by root to start the tomee service. It's not the actual command the init script would run. The init script for this is included below. JAVA_HOME should be set in the init script. /etc/init.d/tomee (needs to be marked executable): #!/bin/bash # description: TomEE Start Stop Restart # processname: tomee # chkconfig: 234 20 80 ...


3

You can stop the process with ctrl-z. Then do whatever you want in the terminal. To continue the process use fg. Or from another terminal, use: kill -19 <pid> It sends SIGSTOP (signal number 19) to the process. This is not possible to catch for the process. To continue the process use: kill -18 <pid> This time it's SIGCONT that brings the ...


0

I think you should be able to hit Ctrl+Z and it'll suspend the process. When you're ready to come back to it, just use fg command and your process will come back to life in the foreground. Or, you could issue a bg command and it'll resurrect your program in background (equivalent to /some/program &)


0

There is no "reverse lookup" for canonical names. That is: given an A record, there is no way to get a listing of what CNAME records point to it.


1

Schematic: ssh ssh A ------> B ------> C ^ ^ using A's using B's ssh key ssh key Preconditions: A is running ssh-agent; A can access B; B can access C; A's ssh public key is present in B:~/.ssh/authorized_keys B's ssh public key is present in C:~/.ssh/authorized_keys In ~/.ssh/config on A, add Host C ...


1

You can see in the end of function _ssh() the block where is ssh browsing ssh config files and later _known_hosts_real -a -F "$configfile" "$cur" which is extracting host names from known hosts files. You can call this command by hand, but the result is returned in variable, not written out: $ . /usr/share/bash-completion/completions/ssh # doesn't have ...


6

Do the exec directly with find rather than via xargs. sudo find . -name *.png -exec optipng -o {} +


2

Using sudo as command to execute by xargs isn't working, as you see. Try it the other way around: find . -name *.png | sudo xargs optipng -o2 The difference is that your version creates a command like sudo optipng -o2 file1 file2 file3 file4 ...... and sudo can't handle so many parameters. Doing it the other way around executes sudo once, which in ...


1

You can use rsync -i. Empty output means no changes. Or rsync --stats and parse the output ...


0

run rsync -n, you'll get list of files that are out of sync: [alexus@wcmisdlin02 Desktop]$ rsync --help | grep dry-run -n, --dry-run perform a trial run with no changes made [alexus@wcmisdlin02 Desktop]$


1

Never done this before, but it might work if your directories are not too big. Create amd5sum before you start your rsync and compare with the md5sum after you finished. Something like this: #!/bin/bash md5sum=$(ssh humbo@hkremote tar -c /home/humbo/dumps|md5sum) . . # The rest of your script goes here . . md5sum_after_rsync=$(ssh humbo@hkremote tar -c ...


0

Rsync does not have exit code that is different for when it runs a copy versus it copies nothing. The exit codes are only for failures resulting in issues with copies. You would have to write some logic around the the function in the bash script to tell if it did not copy any files. http://wpkg.org/Rsync_exit_codes


1

You probably just need to use nohup http://linux.die.net/man/1/nohup


0

You might use screen -d script.sh to start the script with screen in detached mode.


1

You can try something like: time=$(ps -p $processid -o etime= | tr -d ' '); time_in_seconds=$(case ${#time} in "8") echo ${time: -2}+${time: -5:2}*60+${time: -8:2}*3600 | bc;; "5") echo ${time: -2}+${time: -5:2}*60 | bc;; *) echo $(echo $time | cut -d'-' -f1)*86400+${time: -2}+${time: -5:2}*60+${time: -8:2}*3600 | bc;; esac) echo $time_in_seconds Newer ...


1

systemd units support OnFailure that will activate a unit (or more) when the unit goes to failed. You can put something like OnFailure=notify-failed@%n.service And then create the notify-failed@.service service where you can use the required specifier (you probably will want at least %i) to launch the script or command that will send notification. You ...


0

You can also consider the array as a simple variable. In that way, just using if [ -z "$array" ]; then echo "Array empty" else echo "Array non empty" fi or using the other side if [ -n "$array" ]; then echo "Array non empty" else echo "Array empty" fi Using this method can be useful to recover values from a function. The latter writes ...


0

Add the following to your client's config: ServerAliveInterval 60 This will send a no-op every 60 seconds, which will hopefully prevent your firewall from discarding its state tracking entry for your SSH session.


1

You could use something like python-gnupg to have a file encrypted with gnupg. To achieve "real" security you need to put a passphrase to the private key, otherwise you have the encrypted file containing the password and the private key in the same server, so decrypting the file would be trivial. The bad thing of having a passphrase everytime you start your ...


1

check http://stackoverflow.com/questions/13061785/remove-multi-line-comments it has the following script [ $# -eq 2 ] && arg="$1" || arg="" eval file="\$$#" sed 's/a/aA/g;s/__/aB/g;s/#/aC/g' "$file" | gcc -P -E $arg - | sed 's/aC/#/g;s/aB/__/g;s/aA/a/g'


0

#!/bin/bash while read line; do echo $line > /tmp/output.log mail -s 'Event Msg.' 'email@gmail.com' < /tmp/output.log done < <(tail -n0 -F /var/adm/messages)


0

This would be security through obscurity, but there is hardly any other option. If you want to make life hard for the potential thief, I would suggest embedding the key inside the script, and later converting the script into an executable using shc. You might also want to obfuscate the elf itself (Methods to obfuscate an elf.) Keep in mind however, that ...


2

I tried to run that. I did not get a syntax error. In fact it looks mostly good syntax wise. Please see the output below: $ ./a.sh ./a.sh: 3: ./a.sh: Host: not found ./a.sh: 4: ./a.sh: Port: not found Usage: ping [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface] [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos] ...


0

For these of you who needs to pass parameters to the script it should be as follows: ssh user@remotehost "echo `base64 -w0 script.sh` | base64 -d | sudo bash -s <param1> <param2> <paramN>"


0

Ok I resolved my issue! The "find" line stay the same: find . -type f -mtime -200 -fprintf $SCRIPT_DIR/includes.txt "%P\n" And I use the "--files-from" option instead of "--exclude-from" rsync . -e ssh -qrtl --files-from=$SCRIPT_DIR/includes.txt $USER@$DEST_SRV:$DEST_DIR


1

POSIX says: x=10 while [ $x -gt 0 ]; do command x=$(($x-1)) done which could of course be made into a one liner: x=10; while [ $x -gt 0 ]; do command; x=$(($x-1)); done and seems to be the most portable way, and thus less likely to make you install programs. The following are less portable: brace expansion {1..10}: bash specific, and would ...


0

According to man pages, --exclude=PATTERN exclude files matching PATTERN --exclude-from=FILE read exclude patterns from FILE --include=PATTERN don't exclude files matching PATTERN --include-from=FILE read include patterns from FILE The exclusion is made reading pattern from files, and not according to the files names themselves. I ...


0

It is better to use keychain in this case Debian/Ubuntu: apt-get install keychain RHEL/Fedora/CentOS yum install keychain Add in your .bashrc the following: eval `keychain --eval id_rsa`


0

Here's what I came up with it's very simple but it works. Although I think Sven's answer does a better job with basic error handling. #!/bin/sh hostname=`hostname` # Dump DBs date=`date +"%Y%m%d_%H%M%N"` filename="/var/backups/app/${hostname}_${db}_${date}.sql" pg_dump databasename > $filename gzip $filename exit 0 Let me know what you ...


2

Not taking into account any specific syntax for pg_dump: #!/bin/bash $TODAY=`date --iso-8601` $BACKDIR=/backup pg_dump [options] > $BACKDIR/$HOSTNAME-$TODAY if [ "$?"-ne 0]; then echo "Help" | mail -s "Backup failed" you@example.com; exit 1; fi


0

You can use the -L option for curl to have it follow redirects.


2

Assuming your service has a status command, you can do something as simple as in the cron job: 0 0,12 * * * service whatever status >/dev/null || service whatever restart That way, you first run the status check, discard verbose output, and then verify that exit code is not 0 (which would be good), in which case - restart. Indeed, with a ...


2

First of all: you should investigate the "real" problem with supervisord instead of restarting the service every night. That being said, try to use /etc/init.d/supervisor stop / start or restart. Many times cron has problems using service. You also have to create the cron as the user supervisord runs on, or as root via sudo crontab -e. Also always use ...


1

With help from all comments, I wrote a python script to normalize all files recursively: #!/usr/bin/env python # coding=utf-8 import unicodedata import sys,os # Walks recursively through directory and normalizes all filenames to NFC for dirPath, subdirList, fileList in os.walk(sys.argv[1]): for fname in fileList: d = os.path.join(dirPath, ...


0

try: #!/bin/bash # script executed from /home/foo/ touch hi_foo cd /home/bar su bar touch hi_bar you need to run your script with sudo so the process running your script will have sufficient rights to run su bar command


1

The problem is you're not using the -e option with your echo command. Try this: echo -e 'From: "Tester"\ntest' > test2 cat test2 | msmtp email@mail.com -e is for telling echo to interpret escaped chars (like "\n").


1

Here my approach. Use zabbix "log" type key to monitor error pattern in a log-file (/var/log/uwsgi.log is the case here). invoke zabbix remote command triggered by the above 1. This remote command fetch lines surrounding the error by linux command tail(1). The advantages of this approach are: No need to install&setup agent-host side special script ...



Top 50 recent answers are included