Scripting
Install Initial Ubuntu Items GUI
Because of all the great response from the simple shell script, I've created a GUI using Zenity and Bash so that people new to the CLI or those who wish to select and deselect what packages to install or uninstall may do so. You'll be able to play DVDs, listen to your MP3s, have 5.1 Surround Sound playback enabled and more. This isn't a 'how-to' but rather a 'just-do-it'. If you want to know the how-to, just view the source of the script. It's basically doing some simple apt-gets with a GUI front-end.
Below is a screenshot of the window. Just download the shell script here on my server, -- you'll need to extract it (tar xvf ubuntuTasks.sh.tar.gz) then make sure it's executable (chmod +x ubuntuTasks.sh) and execute it (./ubuntuTasks.sh). You'll be greeted with a user-friendly GUI where you can select and deselect items.
steven@steven-laptop:~/fun$ chmod +x ubuntuTasks.sh steven@steven-laptop:~/fun$ ./ubuntuTasks.sh
Once you hit OK, you'll have to input your sudo password when it returns to the CLI. It shouldn't prompt you for anything else. Please shoot me a message if you need any help or have any suggestions.
Initial Ubuntu Install Items Script
UPDATE: Please go here for the new GUI version of this script that also includes some extra items.
I was actually going to write an entry this morning about packages to purge or install upon a fresh Ubuntu build but Ubuntu Linux Help beat me to the punch. It's a great article and well worth the read. I've modified the list slightly and created a bash script to execute it. The file is here. Just extract it ( tar xvf ubuntuTaks.sh.tar.gz ) make sure it's executable ( chmod +x ubuntuTasks.sh ) and execute it using ./ubuntuTasks.sh
Below is the code inside in case you want to just copy and paste it into your own file:
#!/bin/bash sudo apt-get remove --purge mono-common libmono0 sudo aptitude install sbackup sudo aptitude install ubuntu-restricted-extras && sudo aptitude install w32codecs sudo apt-get install msttcorefonts && sudo fc-cache -fv sudo aptitude install vlc sudo aptitude install k3b sudo perl -pi -w -e 's/\; default-sample-channels \= 2/default-sample-channels \= 6/g;' /etc/pulse/daemon.conf
As always, this code comes with no warranties. I have run it on my system and all is well.
Quickie: Data Mining on the Web with PERL
This is a simple web mining script using perl.
#!/usr/bin/perl
use LWP::Simple;
$numPages=$ARGV[0];
open OUTPUT,">/home/user/out.html";
for($i=1;$i<=$numPages;$i++){
print $i."\n";
$content=get("http://coderswasteland.com/node/".$i);
print OUTPUT $content;
print OUTPUT "******************\n";
}
close OUTPUT;
This code is useful to pull information from any Drupal website. It takes the number of pages to crawl as a command line argument and uses that to increment through the site, grabbing articles. The content is then all saved to a single output file, each site separated by a series of asterisks from which you may do whatever regex or parsing is necessary to achieve your desired result.
I have a much longer version of this which does parsing and builds feeds. You may also wish to forgo writing to an output file then later reading from it and just process the information from within $content, split it into logical pieces, etc. This script is merely to get you started. If you're looking into web mining, I assume you already know about parsing and other topics, and this is just a quick way to grab web content.
A spiffier version would be to follow links on a page and popping info onto a tree rather auto-incrementing a URL. this is left as an exercise for the reader :)
Quickie: Burning Video DVDs Command Line Linux
Make sure you have dvdbackup and growisofs/mkisofs. (Your usual sudo apt-get install in Debian/Ubuntu).
Simply:
dvdbackup -i /dev/dvd -M -o </your/output/path> growisofs -speed 1 -dvd-compat -Z /dev/dvdrw -dvd-video </your/output/path/videodir>
Example:
dvdbackup -i /dev/dvd -M -o /home/steven/Documents/VID/ growisofs -speed 1 -dvd-compat -Z /dev/dvdrw -dvd-video /home/steven/Documents/VID/MY_BACKUP_VIDEO/
The second path is where the first command wrote to. Basically it will be one folder deeper than that first path. It is the path that contains the VIDEO_TS directory.
Referenced from:
http://ubuntuforums.org/showthread.php?t=133642
Quickie: Multiple File Search and Replace
If you've ever run into the necessity to change the same data over multiple files you know how hard it is to go through each and every file and update it by hand or at best do an indiviual regex on each. Here's how you can make the changes all in on fell swoop.
perl -pi -w -e 's/searchregex/replaceregex/g;' *.fileextension
-w display any warnings
-i in place edit
-p loop over files
-e execute this line of code
Here's an example:
perl -pi -w -e 's/\x0D//g;' *.txt
This looks for those pesky ^M characters and replaces them with nothing.
Quickie: Strip ^M (Control-M) Characters from Input File with PERL
For anyone that does file I/O and has to sometimes work with Windows-generated files in Linux, I feel your pain. Windows has these little nuances that sometimes makes our GNU/Linux world a fun place to live. Luckily, PERL has a simple little system in place that allows us to remove control characters - Regular Expressions. Those not familiar will find great references at http://www.regular-expressions.info/ (a fantastic place to begin) and http://www.regextester.com/ (where you can test your brilliant work).
People who just want a quick piece of code, look no further:
If you want to do it all in one line from the CLI (of course replace *.txt with whatever extension):
perl -pi -w -e 's/\x0D//g;' *.txt
If you'd rather do it inline in a Perl script:
#Good Code $yourLine =~ s/\x0D//g; #strips ^M characters
Simply trying to strip ^M characters with
#Bad Code $yourLine =~ s/\^M//g; #strips ^M characters
unfortunately does not work. The previous hex value works great for me. I've run into this problem many times while taking third party data feeds which are sometimes generated in Windows and trying to preprocess them in my GNU/Linux environment. The ^M sends gets interpreted as a new line and wreaks havoc on feeds where you expect all the information to be on one line in a fixed number of columns.
For more information on control characters, please go to: http://www.cs.tut.fi/~jkorpela/chars.html where Jukka Korpela explains in-depth what control characters are, what issues you may have, and how you may go about resolving them.



![[FSF Associate Member] [FSF Associate Member]](http://www.ossolutions.org/lores/img/fsfMember.png)
Subscribe to this Feed