Archive

Tag Archives: BASH


get_iplayer is command line program which is able to interface with the BBC’s iPlayer service, return a play list of ALL available content, and fetch any particular files/shows that are requested. its probably in your repo, if not head over to http://linuxcentre.net/ and grab it now!

This software is a celebration for all who believe in open source and freedom on the internet. However, sadly the BBC has closed the door on get_iplayer from streaming programs directly (without first downloading)… forcing people to install and use the ghastly flash player for direct streaming.

Invoke the program without arguments and get_iplayer will print a list of hundreds of available files.

$ get_iplayer

But it would be easier to read it if it was saved to a text file…

$ get_iplayer > ~/iplayer.txt

What about radio content?

$ get_iplayer --type radio > ~/iplayer_radio.txt

Look through the lists for what you want, and and then use the ‘–get’ option along with the program ID and your download will begin.

$ get_iplayer --get 12955

and yes, you can ask get_iplayer to download multiple files with one command, just seperate each shows ID with a space.

Ingeniously, get_iplayer tricks iPlayer into thinking an iPhone is making the request, and serves up the files right away. for this reason, the feeds arent exacly high definition, but still very watchable.

Advertisements

Often, when using linux, there are times when you need to re-use a long-winded command on a regular basis. Wouldnt it be nice if you could configure your system to carry out that command with just a simple keyword commmand?

Well luckily for us, we can. let me give you an example. The command i use if i want to watch a video within the framebuffer (ouside of X) is as follows:

sudo mplayer -vo fbdev -fs -vf scale=800:-3 /name/of/video.avi

There is no way i’m going to remember that everytime i come to watch a video… Now sure, i could save this into a txt file and grab it when i need it, or even write a script to handle it, but there is a more elegant way. Use an alias.

An alias is just like giving your own unique name to a command for simplicity. I want my alias to be ‘clivid’ so that i can type ‘clivid /path/to/video.avi’ and the computer will do – ‘sudo mplayer -vo fbdev -fs -vf scale=800:-3 /path/to/video.avi’

Heres what you do: open a terminal emu, type

sudo leafpad ~/.bashrc

Or whatever txt editor you use if you dont like leafpad.

You will be confronted with your .bashrc file. Scroll to the very bottom, this is where we will add the alias

First add a comment so you know what the alias does my case its:

#Alias for opening mplayer within framebuffer

Next is the line which actually adds the alias

alias clivid='sudo mplayer -vo fbdev -fs -vf scale=800:-3'

its that simple. You type alias nameOfAlias=’bashCommand’

Save the document, and you’re almost finished. You must recompile .bashrc, type:

source ~/.bashrc

Now test out your new alias on the command line – good luck!

I frequently find, when I run htop, that X is sucking up ~25% of my CPU. From what I have researched it seems I might have an issue with my video driver.

Given that I havent yet found a solution to this,  I like to run my system without X when possible. One quick fix that makes this so much more pleasurable is to us a framebuffer.

Using a framebuffer allows you to run the command line in a higher resolution than normal, it also lets you display images, browse the net with a graphical CLI browser, and even watch video.

The easiest way to do this is to edit ‘/boot/grub/menu.lst’

start by typing ‘sudo leafpad /boot/grub/menu.lst’ on the command line and press enter. If you dont use leafpad, replace that with your favourite text editor.

When that opens, scroll down and you will see something that looks a bit like this:

title        Ubuntu 8.10, kernel 2.6.27-8-eeepc-lean
uuid        01225088-77c2-4dc9-8113-2ef89ac2f7e8
kernel        /boot/vmlinuz-2.6.27-8-eeepc-lean root=UUID=01225088-77c2-4dc9-8113-2ef89ac2f7e8 ro quiet splash
initrd        /boot/initrd.img-2.6.27-8-eeepc-lean
quiet

Depending on your grub config, you might have more than one of these – the top one should be your default boot.

On the end of the kernal line, where it says ‘splash’ you need to type ‘vga=xxx’. The xxx should be replaced by 3 digits based on what colour depth and resolution you want. for example, mine is ‘vga=788’ which is 800×600 16bit. See this page for a table outlining possible setups and the relevant codes.

Once that is done, save and restart your system – you should now have a framebuffer on your command line!

to try it out, download fbi (a command line  image viewer) ‘sudo apt-get install fbi’

then ‘fbi ~/some/image.png’ and you’ll see for yourself!

This worked perfectly for me on my EEE900 running chunchbang. I take no responsibility if you muck up your system. GOOD LUCK!

I just threw together a quick shell script to automate the process of unraring multiple rars.

enter a directory containing rars to be extracted, a password if required, and just walk away =)

enter a directory containing rars to be extracted, a password if required, and just walk away =)

The script searches for all .rar files within a user specified directory and then one by one applies an unrar command to each. The script will work for passworded archives too, or if they have different passwords, enter one at a time

Currently split archives are not supported by this script, so be warned.

If you use a lot of rar files, or are a rapidshare user, take a look and try it for your self

echo "Enter path of dir which contains rar files for extraction"
read thedir

echo "The script will now attempt to extract the following files"
ls $thedir
echo "if these files are password protected, enter password now... (if not, type 0)"
read $rarpass

if [ "$rarpass" == 0 ]; then

	for f in "$thedir/*.rar"; do
			
			unrar e -v $f
	done
	

else

	for f in "$thedir/*.rar"; do
	
			unrar -prarpass e -v $f
	done
fi