Linux helper scripts

Here is a small collection of linux helper scripts I made for myself, and now decided to share with the world... Hope you find them useful...

Update: May 12th 2009: Scripts will be addedd real soon, within a day or two, depends on my workload, and other stuff... But expect it here, until the end of week...

Update 2: May 23rd 2009: I had some trouble with the infamous Seagate ST3500320AS... It's only been 6 months of age, when it failed me... And being my primary hard drive, you can imagine the frustration... Luckily, there was a fix, and with a help of an experienced engineer, I got it back, with all the data intact... For now, I'll only include a single script, which you should copy/paste in your favourite editor, and save wherever you like... And don't forget - always remember to set eXecution privileges on that script... It's still a bit messy, but I'll add more scripts soon, and they'll also be available for download, nicely formatted...

This script is a helper script for mounting/unmounting ISO CD images:

CODE:

#!/usr/bin/perl my $loop = 0; my $iso = ""; my $isof = ""; my $isod = ""; my $cmd = ""; $cmd = shift(@ARGV); $iso = shift(@ARGV); print "ISOMount - ISO CD Image mount-wrapper script\n"; print "Written in 2008. by Slobodan Todorov code@todorowww.net\n\n"; if (!defined(@ARGV)) { print "Usage:n"; print "tMounting:tisomount -m 'iso image name'\n"; print "tUnmounting:tisomount -u 'mounted iso name'\n"; exit; } if ($cmd eq "-m") { if ($iso =~ m/(.*/)(.*)$/) { $dir = $1; $file = $2 } else { $dir = ""; $file = $iso; } print "Checking for existance of iso file... "; if (-e "$dir$file") { print "Exists.n"; } else { print "NON existant.n"; print "File '$dir$file' doesn't exist.n"; exit; } $isof = $file; $isof = "$dir$isof"; $isof =~ s/ / /g; $isod = $file; $isod =~ s/.iso$//; $isod =~ s/ / /g; $ison = $file; $ison =~ s/.iso$//; print "Checking for loaded loop module... "; open(MP, "modprobe -l loop|"); while () { my $line = $_; chomp($line); if (m/loop.ko/i) { $loop = 1; } } close(MP); if ($loop eq 0) { print "NOT loaded. Loading... "; system("sudo modprobe loop"); print "Done.\n"; } else { print "Loaded.\n"; } print "Checking for ISO directory... "; if (-d "/media/$ison") { print "Exists.n"; } else { print "NON existant. Creating... "; system("sudo mkdir /media/$isod"); print "Done.n"; } $iso =~ s/\ /\\\ /g; print "Mounting ISO image... "; system("sudo mount $isof /media/$isod -t iso9660 -o loop"); print "Done.\n"; } else { print "Checking for mounted directory... "; if (-d "/media/$iso") { $iso =~ s/\ /\\\ /g; print "Exists.\nRemoving mount directory..."; system ("sudo umount /media/$iso"); system("sudo rmdir /media/$iso"); print "Done.\n"; } }
Website by Slobodan Todorov.
Made with free software.