Hot answers tagged

39

From crontab(5): The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless escaped with backslash (), will ...


19

Powershell primarily uses new lines as statement seperators, but semicolons may be used for multiple statements on a single line.


12

For anyone trying to understand what usage output means, the best way is to man man. seriously :-) Take the time to learn the conventions, it really helps. The following conventions apply to the SYNOPSIS section and can be used as a guide in other sections. bold text type exactly as shown. italic text replace with appropriate ...


7

In BIND's zone file as well as in named.conf, IN is a class. You can omit it in any of the files or in both, in any case if class is not explicitly specified, the default "IN" is used. Regarding the meaning of "IN" - RFC 1035 section 3.2.4: The following CLASS mnemonics and values are defined: IN 1 the Internet ...


6

The key, no matter whether you choose to use semicolons or not, is to be consistent. If you are used to using them in C#, then continue to use them in PowerShell. If you don't want to use them, then don't use them. Pick a standard and stick with it for you and the people that will read and use your code. It will get ugly if you decide halfway through a ...


5

You are missing a semicolon (and I'm not sure if it works without square brackets). Alternatives: if [[ $? -ne 0 ]];then or if ! test $? = 0; then or if [ $? -ne 0 ];then or test $? = 0 || echo 'error'; or even better: rm /bla/bla || echo 'error'; (the last one is your whole script)


4

I had a lot of problems with backticks also. Sometimes you need more than one occurrence of quotes and backticks. Just replace them for $(). Example: export NOW=`date` by export NOW=$(date) -Gilson Soares


4

sudo -u user command will run command as user without the need to invoke su. You will need to set it up in your sudoers file first. Also, you could put the command you want to run in a small script and sidestep the quoting problems.


4

man ssh man sshd man ssh_config man sshd_config http://www.ietf.org/rfc/rfc4251.txt should tell you everything you need to know.


3

The suggested way to execute local commands remotely via ssh is not to use eval. This is discouraged. Since you are storing the whole line in a variable, instead you could mydate=$(date; date; date); ssh rsync@example.org bash <<< "$(printf 'echo %q ' "$mydate")" Eval should only be used in legacy systems who do not provide safe tools like the ...


3

You seem to miss the most important line: auto xenbr0 iface xenbr0 inet static bridge_ports eth0 eth4 eth7 # bridge traffic between these interfaces bridge_stp no address 10.0.0.1 netmask 255.255.255.0 network 10.0.0.0 broadcast 10.0.0.255 man says: If you need to specify the interfaces more flexibly, you can use the following syntax ...


3

Always thought it means Internet Number. According to Wikipedia is actually just Internet: The CLASS of a record is set to IN (for Internet) for common DNS records involving Internet hostnames, servers, or IP addresses.


3

range is a reserved word in 5.1 http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html So if you use it, you need to use the back ticks in order to tell mysql that you aren't using the reserved word. range wasn't in 5.0


3

Backsticks and $(...) are identical in terms of functionality. However I prefer the second approach $(...) can be easily nested readability, $(...) is more "bashish" consistency, as a similar syntax, $((...)), is for expressions See also this page that has other arguments.


2

The allowable syntax for the expansion can be seen in the message_expand function in LimitsOld.pm. As far as I can tell it doesn't implement enough control structures to do what you want. Alternative approach would be to pass the notifications through an intermediary (Nagios for example or a script of your own devising) and apply logic/reformatting there.


2

Try: update Table1 t1 set t1.Firstname = 'Temp1' inner join Table2 t2 on t1.Id = t2.Id -- Whatever your PK and FK are here where t1.Firstame = 'xxx' and t2.CreateTS < '2014-02-08 15:00:00.000'


2

Here below you have the answer. To highlight the change, I inserted two FirstName as 'not_updated'. Please, see SQL_Fiddle update Table1 join Table2 on Table1.id = Table2.id set Table1.FirstName = 'Temp1' where Table2.CreateTS < '2014-02-08 15:00:00.000'; I hope this helps.


2

If you're looking to remove/replace specific lines, or parts of lines, it's often better to try and be as specific as possible. In your case you'll want to try and more closely match the text after from and the server name and ip. Something like this should do a better job: ([a-z]{2,25} \(.*\[.*\]\))


2

Here's a very handy alternative. The "test" command is itself a command like "rm". It sends a return code to "if": 0 if it succeeds and 1 or greater if it fails. So instead of checking the return code in the special $? variable, you can just do this: if rm foo; then echo "It worked" else echo "It failed" fi You can also negate the if by doing ...


2

Are you sure? Maybe there are is a symlink and the destination path actually is a subfolder of the source path. Compare the output of readlink -e /home/admin/Downloads/folder1 and readlink -e /home/admin/MyLibrary/MyVideos/TV/folder1.


2

Those are conditional loads. If a specific Apache module is loaded, then allow that configuration block to take effect. If the modules are not loaded, they're not executed.


2

Note that the leading '#' on a line in an Apache config file indicates a comment. The actual syntax to execute statements only if a given module is already loaded is simply: <IfModule ...> statements to execute... </IfModule> If you copy blocks of statements with the start and end conditional statements commented out, then the lines within ...


2

First of all, while there are general conventions, they are not uniformly applied. In this case, it's saying that if you use -R (indicating "recursion"), then you can use either -H, -L, or -P. If you don't use -R, then those options are not relevant. Yes, case is almost always important. So usually -h and -H do completely different things. The square ...


2

[Answering own question after getting around to prodding at the config for a while] I've managed to track this down to one of the modules which I have written (of course), but it was due to a use of a variable which didn't work out how I expected. What happened was: $variable_dir = "/etc/puppet/bar" class foo { file { $variable_dir: ensure => ...


2

There is no native .htaccess validator. If a third party tool exists, I am not sure if I would trust it. Since it is a script that modifies the file, you should be able to code the validation within your script. You can also include testing and verification processes for your deployment, which would help reduce mistakes.


2

Here two useful, free services: This one lets you upload an .htaccess file for validation. This one lets you paste the contents of an .htaccess file into a textbox for validation.


2

There is no reason to compose such a long string of commands to run via SSH. Just make a permanent script on the remote host called /usr/local/sbin/rotate_backups and call it with ssh $USER@$HOST 'sudo /usr/local/sbin/rotate_backups'. If you were asking this on the "Unix & Linux" StackExchange, then this could be an interesting question. However, as ...


2

Try this: user@server:~$ remote_cmd=(ssh rsync@otherserver.example.org 'date; hostname -A; uname -a') user@server:~$ "${remote_cmd[@]}" It creates an array and executes it as suggested in BashFAQ/050 item 3.


2

EDIT Just a quick note to say, one way to avoid having your Apache server hosed if the config file chokes due to a change is to first reload Apache to see how it parses the config. sudo service apache2 reload The nice thing about reload is it will attempt to reload the settings in a config file, but it won’t force the server to stop or restart. If it ...


2

The elaborate precautions against $TRUE being empty are not needed if double quotes are used. [ "$TRUE" = 'true' ] The -z tests if $TRUE is not empty, and :- substitutes nothing if it is unset. It is all unnecessary. Perhaps it is a protest against an over-prescriptive coding standard.



Only top voted, non community-wiki answers of a minimum length are eligible