Edmonds Commerce » bash http://www.edmondscommerce.co.uk Freelance PHP Ecommerce and SEO Developer in the UK Thu, 11 Apr 2013 11:06:19 +0000 en-US hourly 1 http://wordpress.org/?v=3.5.1 Apache Log File Analysis Script http://www.edmondscommerce.co.uk/bash/apache-log-file-analysis-script/ http://www.edmondscommerce.co.uk/bash/apache-log-file-analysis-script/#comments Thu, 14 Mar 2013 14:17:48 +0000 Joseph Edmonds http://www.edmondscommerce.co.uk/?p=4142 Here is a little bash script we knocked together to track down some malicious activity on a clients server. Using a bit of awk etc to parse the log files we could quickly track down an IP address that was overloading the server and then take steps to block that person. Here is the script: [...]

The post Apache Log File Analysis Script appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/apache-log-file-analysis-script/feed/ 0
Bash timeout and copying text in vim http://www.edmondscommerce.co.uk/bash/bash-timeout-and-copying-text-in-vim/ http://www.edmondscommerce.co.uk/bash/bash-timeout-and-copying-text-in-vim/#comments Thu, 14 Mar 2013 12:59:42 +0000 ross http://www.edmondscommerce.co.uk/?p=4137 I have been working with a server that had been configured differently from the way that I prefer. The two biggest complaints that I had about it were that the timeout was set very low, meaning that the connection would break off every five minutes, and that vim had been set up so if you [...]

The post Bash timeout and copying text in vim appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/bash-timeout-and-copying-text-in-vim/feed/ 0
Simple Bash Single Process Enforcement http://www.edmondscommerce.co.uk/bash/simple-bash-single-process-enforcement/ http://www.edmondscommerce.co.uk/bash/simple-bash-single-process-enforcement/#comments Thu, 21 Feb 2013 15:06:39 +0000 Joseph Edmonds http://www.edmondscommerce.co.uk/?p=3985 If you have a bash script that you want to make sure there is only ever one instance of, for example something triggered by cron that might not have finished the next time cron tries to trigger it then you might like this little snippet: This is built for running Magento shell scripts (if you [...]

The post Simple Bash Single Process Enforcement appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/simple-bash-single-process-enforcement/feed/ 0
Correct recursive backups in bash http://www.edmondscommerce.co.uk/bash/correct-recursive-backups-in-bash/ http://www.edmondscommerce.co.uk/bash/correct-recursive-backups-in-bash/#comments Wed, 20 Feb 2013 20:54:57 +0000 ross http://www.edmondscommerce.co.uk/?p=3979 Sometime a backup script can go wrong, and rather the overwrite the old files you place a copy of the new ones into the same folder. This can then escalate and before you know it you have multiple levels of the same files. If you just want to flatten these files then this script can [...]

The post Correct recursive backups in bash appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/correct-recursive-backups-in-bash/feed/ 0
Bash Terminal Rename Programmatically http://www.edmondscommerce.co.uk/bash/bash-terminal-rename-programmatically/ http://www.edmondscommerce.co.uk/bash/bash-terminal-rename-programmatically/#comments Wed, 16 Jan 2013 12:56:15 +0000 Joseph Edmonds http://www.edmondscommerce.co.uk/?p=3864 If you have a load of terminals open you might find it handy to be able to rename the window title on the fly. You can do this easily by copying this code into your ~/.bashrc file (or even pasting it into your terminal if you like) If you have pasted this into your ~/.bashrc [...]

The post Bash Terminal Rename Programmatically appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/bash-terminal-rename-programmatically/feed/ 0
Bash Redirection not Working in Shell Scripts + Solution http://www.edmondscommerce.co.uk/bash/bash-redirection-not-working-in-shell-scripts-solution/ http://www.edmondscommerce.co.uk/bash/bash-redirection-not-working-in-shell-scripts-solution/#comments Wed, 09 Jan 2013 15:54:46 +0000 ross http://www.edmondscommerce.co.uk/?p=3840 I recently needed to trigger a couple of bash scripts through a web browser. Unfortunately PHP shell_exec function grinds to a halt when it is used to trigger a long running / memory intensive script when it is used with Apache. To get round this I instead wrote the command to a file and then [...]

The post Bash Redirection not Working in Shell Scripts + Solution appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/bash-redirection-not-working-in-shell-scripts-solution/feed/ 0
Tip: Remove spaces from filenames one-liner http://www.edmondscommerce.co.uk/bash/tip-remove-spaces-from-filenames-one-liner/ http://www.edmondscommerce.co.uk/bash/tip-remove-spaces-from-filenames-one-liner/#comments Mon, 26 Nov 2012 16:16:58 +0000 martyn http://www.edmondscommerce.co.uk/?p=3704 There is often the case when you need to remove spaces from filenames – for instance when importing broken data feeds into Magento or osCommerce systems. The following strips spaces and replaces them with nothing :- or alternatively replace them with underscores :- Or any other character/string combo you like, you can even be more clever moving [...]

The post Tip: Remove spaces from filenames one-liner appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/tip-remove-spaces-from-filenames-one-liner/feed/ 0
Tip: Parse XML Values in bash e.g. Magento local.xml http://www.edmondscommerce.co.uk/bash/tip-parse-xml-values-in-bash-e-g-magento-local-xml/ http://www.edmondscommerce.co.uk/bash/tip-parse-xml-values-in-bash-e-g-magento-local-xml/#comments Thu, 23 Aug 2012 11:37:58 +0000 admin http://www.edmondscommerce.co.uk/?p=3334 Not the most elegant way to do this, and probably could do with some extra tweaks but it works for our purposes, so presented here in case it fits yours : It also strips out the CDATA tags, which we needed to pull the database details from Magento’s local.xml To use this to get, for [...]

The post Tip: Parse XML Values in bash e.g. Magento local.xml appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/tip-parse-xml-values-in-bash-e-g-magento-local-xml/feed/ 0
Format searched log files http://www.edmondscommerce.co.uk/bash/format-searched-log-files/ http://www.edmondscommerce.co.uk/bash/format-searched-log-files/#comments Thu, 16 Aug 2012 15:45:56 +0000 admin http://www.edmondscommerce.co.uk/?p=3277 When you are monitoring a log file you may want to narrow it down, and format the results. This simple one line command will break up the output from a log file to make it easier to quickly read tail -f /path/to/log | grep "search term" | sed 's/\(.*\)/----------\n\1\n----------/' More Reading: Bash timeout and copying [...]

The post Format searched log files appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/format-searched-log-files/feed/ 0
TIP: SSH add a tunnel to a running session http://www.edmondscommerce.co.uk/bash/tip-ssh-add-a-tunnel-to-a-running-session/ http://www.edmondscommerce.co.uk/bash/tip-ssh-add-a-tunnel-to-a-running-session/#comments Wed, 28 Mar 2012 11:39:09 +0000 admin http://www.edmondscommerce.co.uk/?p=3060 Useful tip – if you’ve ever been ssh’d into a remote machine and don’t want to break the connection or open a new session just to add a new tunnel, there is a way Press [return] then ~ then C to get to an ssh prompt, then you can add tunnels as you would at [...]

The post TIP: SSH add a tunnel to a running session appeared first on Edmonds Commerce. Edmonds Commerce are Magento specialist developers based in the UK.

]]>
http://www.edmondscommerce.co.uk/bash/tip-ssh-add-a-tunnel-to-a-running-session/feed/ 0