Bash Shell Script to Automate FTP File Transfer
A little script to send a backup file to a remote FTP server: 12345678910111213141516#!/bin/bash HOST=’123.111.123.111′ USER=’bak_user’ PASSWD=’OpEnSeSaMe’ TODAY="$(date +"%Y%m%d")" FILENAME=Hostname_$TODAY.tgz cd /var/backup/sched/ ftp -n -v $HOST << EOT ascii user $USER $PASSWD prompt cd backups put $FILENAME ls -la bye EOT Then run it every day from Cron.
Continue ReadingAdaptec Hardware RAID controller on Sun 4150
On our Oracle Sun x4150′s the Hardware Raid can be checked after installing the StorMan software which is available (as StorMan-6.40.x86_64.rpm) in the software bundle for x4150s available after logging in to the Oralce support website and locating the downloads for x4150s. The download is pretty big (931MB) when the 39MB RPM is all you are [...]
Continue ReadingUsing Sed to convert Mac Address
I have output from a router (but I believe modem output may be similar) with mac addresses in the format: 0050.56AC.4022 Four digit blocks separated by dots but I needed it in the format of 2 digit blocks separated by colons. My router output was lines like this: INTERNET 123.111.123.111 8 0050.56AC.1765 ARPA VLAN.1.16 [...]
Continue ReadingWeb Screenshots with Xvfb and Khtml2Png2
To get that headless Linux server capturing screenshots of web pages we need: Xvfb e.g. apt-get install xvfb Khtml2png2 (and dependencies) After installation of the above the steps are below and I wrapped it up into a PHP script which also did some database tasks to keep records of the screenshots. 1.Check if the Xvfb [...]
Continue ReadingRemove Line Breaks with tr
I had a text file with multiple lines of input that I was manipulating using awk and sed but I found the following ‘tr’ command easiest to remove the line breaks: cat input.txt | tr -d ‘\n’
Continue ReadingZero Filling a Disk in Linux
The simple way to wipe or zerofill a disk is: dd if=/dev/zero of=/dev/sd? bs=1M However I found an article describing how to zero-fill with a progress indicator using pipebench, installed on Debian/Ubuntu with: sudo apt-get install pipebench then use: tr ‘\000′ ‘\377′ < /dev/zero | pipebench | sudo dd of=/dev/sd? Substitute the question mark for [...]
Continue ReadingBash: Looping through Files with Spaces
I was trying to move some miscellaneous music files into directories by artist name. The files (and folders) have spaces in the file names. For my first attempt I tries a for loop e.g. for file in $(find /path/to/music -type f); do … done A for loop will not do this regardless of how much [...]
Continue ReadingFinding, Searching, Replacing & Deleting Strings in Files
To find a text string within files in all sub-directories: find . -type f | xargs -r0 grep -F ‘dodgystring’ or find . -type f -exec grep -l “dodgystring” {} \; To replace a string within files in all sub-directories: find ./ -type f -exec sed -i ‘s#fromstring#tostring#’ {} \; From within vi replacing all [...]
Continue Readingecho with new lines
For future reference: echo “This does not give \n a new line” does not work. I had used printf sometimes but the -e switch also works for echo: echo -e “This gives \n a new line”
Continue Readingnslookup mx records
$ nslookupDefault Server: dnsserver.comAddress: 111.222.111.222> set q=mx> mymailserver.domain.com
Continue Reading
Recent Comments
Thanks - worked for me....
30 days agoyou can use partprobe command to eliminate the need for reboot....
52 days agoThanks alot for this simple and solid post....
57 days agoI'm using this company services (ssl2buy) since long and purchased man...
57 days ago