Ubuntu tips and trials
Converting .FLAC files to high quiality .MP3 files with only one command 
Monday, August 18, 2008, 17:19
Posted by Administrator
So you have your nice lossless audio all compressed into FLAC. How do you quickly convert them to high quality mp3's to stick on your ipod or some other mp3 player? I've written a script below that will do it for you in one easy step. It takes a few steps to set it up first, but once it's done you'll only ever need to type one command.

First, you'll need to install FLAC and lame 3.97

sudo aptitude install flac

sudo aptitude install lame


As of this writing the Ubuntu repositories still has lame 3.97 as the current. I've configured my script to take advantage of the new vbr algorithm with the --vbr-new switch. When the repositories are updated or you compile lame 3.98 yourself, edit the script to comment in the v3.98 line and comment out the v3.97 line

Now you'll need to get my script. Change to the /bin folder like so:

cd /bin


now type this:

wget www.mellowd.co.uk/scripts/encode


Now you'll need to make that file an excecutable like so:

chmod +x encode



Now all you need to do is go into the folder that has your flac files and type:

encode


The script will decode all the .flac files to .wav in a new subfolder, stripping the .wav suffix. It will then run lame to create mp3's in a new folder in the original folder using the -q0 setting which is the nest VBR setting available with lame. It will then delete all the .wav files and subfolder and finally it will add the .mp3 suffix to all your new mp3's.

When it's complete you'll have an mp3 folder in your original folder, full of high quality mp3's


This is the contents of the current script itself as of today:

# Encode
# v0.2 18.08.08 - Second draft, changed the default to lame 3.97 as this is what's in the Ubuntu repositories
# v0.1 17.08.08 - First created
# Darren O'Connor <mellow.drifter@gmail.com>

# This script, when run in a folder full of FLAC files, will create high quality VBR mp3's for use in mp3 players.
# This version uses lame 3.98 and 3.97. Please edit out the appropriate line below (Don't leave them both in!)

#!/bin/bash
mkdir wav/
flac -d *.flac
mv *.wav wav/
cd wav/
for f in *.wav; do mv "$f" "${f%.wav}";done
mkdir ../mp3/

# If you use lame 3.98 then comment IN the next line and comment out the following line
# find -maxdepth 1 -type f -name '*' -exec lame -V0 -q0 '{}' -o '../mp3/{}' \;

# If you use lame 3.97 then comment IN the next line and comment OUT the previous line
find -maxdepth 1 -type f -name '*' -exec lame --vbr-new -V0 -q0 '{}' -o '../mp3/{}' \;

cd ../mp3/
for FILE in *; do mv "$FILE" "$FILE.mp3"; done
cd ../
rm -r wav/


add comment   |  permalink   |   ( 0 / 0 )
Setting up a terminal server on a cisco device 
Sunday, June 15, 2008, 19:46
Posted by Administrator
I've been practising a lot of various BGP/OSPF/EIGRP and IS-IS things at work. I've set up a lab there which will allow me from home to access all of these devices through their console ports without actually sitting in front of them.

In order to do that I've used an old 2600 with a 32 port async serial card. It's a very simple config and I've pasted it here:


!
version 12.2
service timestamps debug uptime
service timestamps log uptime
service password-encryption
!
hostname TerminalServer
!
enable secret 5 <removed>
!
ip subnet-zero
!
!
no ip domain-lookup
ip host R7 2048 192.168.1.1
ip host R5 2037 192.168.1.1
ip host R1 2033 192.168.1.1
ip host R2 2034 192.168.1.1
ip host R3 2035 192.168.1.1
ip host R4 2036 192.168.1.1
ip host R6 2038 192.168.1.1
ip host S1 2039 192.168.1.1
ip host S2 2040 192.168.1.1
!
call rsvp-sync
!
!
!
!
!
!
!
!
interface Loopback0
ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address <removed>
duplex auto
speed auto
!
ip default-gateway <removed>
ip classless
ip route 0.0.0.0 0.0.0.0 <removed>
no ip http server
!
!
dial-peer cor custom
!
!
!
!
line con 0
line 33 64
no exec
transport input all
line aux 0
line vty 0 4
exec-timeout 60 0
password 7 <removed>
login
line vty 5 15
exec-timeout 60 0
password 7 <removed>
login
!
end



There are a few important things to note here. You need to set up an IP address on a loopback interface. I've used 192.168.1.1 on this example.

You then set up IP hosts in this format:
ip host R1 2033 192.168.1.1

R1 = The name I want to refer to the device, this case beig the first router.
2033 = The serial port. The serial port will be 2000 + the serial port number. 33 being my first serial port. (It could be different on yours, I'll add how to check at the end)
192.168.1.1 = The loopback interface. It doesn't matter which address you use, but I'd put on a private address.

The second important part is this:
line 33 64
transport input all


line 33 - 64= The available port on the async card I've used.
transport input all = Allow all protocols (including telnet) through these lines.

You need to check which ports are available on your router. Check to see if those ports are recognised in the first hand by doing a simple show ver

1 FastEthernet/IEEE 802.3 interface(s)
32 terminal line(s)
32K bytes of non-volatile configuration memory.
16384K bytes of processor board System flash (Read/Write)


This particular device has 32 terminal lines, through the add on card. If the router has these ports built in it will be slightly different. Cisco reserves the first 32 lines for built-in ports, whether the router has it or not. As this router has an add-on card, I can't use the first 32 lines. If I try I'll get this:

#line 1
No physical hardware support for line 1



A quick way to check which lines are available is to type this:

show line

TerminalServer#sh line
Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
0 CTY - - - - - 0 0 0/0 -
33 TTY 9600/9600 - - - - - 1 15 2828/8487 -
34 TTY 9600/9600 - - - - - 1 21 2846/8541 -
* 35 TTY 9600/9600 - - - - - 0 18 3112/9338 -
* 36 TTY 9600/9600 - - - - - 0 44 3363/10099 -
* 37 TTY 9600/9600 - - - - - 0 11 3085/9254 -
* 38 TTY 9600/9600 - - - - - 0 11 3149/9446 -
* 39 TTY 9600/9600 - - - - - 0 0 3303/9905 -
* 40 TTY 9600/9600 - - - - - 0 0 3266/9800 -
41 TTY 9600/9600 - - - - - 0 0 0/0 -
42 TTY 9600/9600 - - - - - 0 0 0/0 -
43 TTY 9600/9600 - - - - - 0 0 0/0 -
44 TTY 9600/9600 - - - - - 0 0 0/0 -
45 TTY 9600/9600 - - - - - 0 0 0/0 -
46 TTY 9600/9600 - - - - - 0 0 0/0 -
47 TTY 9600/9600 - - - - - 0 0 0/0 -
* 48 TTY 9600/9600 - - - - - 0 0 3319/9957 -
49 TTY 9600/9600 - - - - - 0 0 0/0 -
50 TTY 9600/9600 - - - - - 0 0 0/0 -
51 TTY 9600/9600 - - - - - 0 0 0/0 -
52 TTY 9600/9600 - - - - - 0 0 0/0 -
53 TTY 9600/9600 - - - - - 0 0 0/0 -
54 TTY 9600/9600 - - - - - 0 0 0/0 -
55 TTY 9600/9600 - - - - - 0 0 0/0 -
56 TTY 9600/9600 - - - - - 0 0 0/0 -
57 TTY 9600/9600 - - - - - 0 0 0/0 -
58 TTY 9600/9600 - - - - - 0 0 0/0 -
59 TTY 9600/9600 - - - - - 0 0 0/0 -
60 TTY 9600/9600 - - - - - 0 0 0/0 -
61 TTY 9600/9600 - - - - - 0 0 0/0 -
62 TTY 9600/9600 - - - - - 0 0 0/0 -
63 TTY 9600/9600 - - - - - 0 0 0/0 -
64 TTY 9600/9600 - - - - - 0 0 0/0 -
65 AUX 9600/9600 - - - - - 0 0 0/0 -
* 66 VTY - - - - - 6 0 0/0 -
67 VTY - - - - - 1 0 0/0 -
68 VTY - - - - - 0 0 0/0 -
69 VTY - - - - - 0 0 0/0 -
70 VTY - - - - - 0 0 0/0 -
71 VTY - - - - - 0 0 0/0 -
72 VTY - - - - - 0 0 0/0 -
73 VTY - - - - - 0 0 0/0 -
74 VTY - - - - - 0 0 0/0 -
75 VTY - - - - - 0 0 0/0 -
76 VTY - - - - - 0 0 0/0 -
77 VTY - - - - - 0 0 0/0 -
78 VTY - - - - - 0 0 0/0 -
79 VTY - - - - - 0 0 0/0 -
80 VTY - - - - - 0 0 0/0 -
81 VTY - - - - - 0 0 0/0 -

Line(s) not in async mode -or- with no hardware support:
1-32


That output will straight away tell me which lines I can and cannot use





add comment   |  permalink   |   ( 0 / 0 )
Converting .daa files to .iso files 
Sunday, January 20, 2008, 19:47
Posted by Administrator
so you've just downloaded a .daa file and want a quick easy way to convert it to a .iso image?

First you need the freeware poweriso application:

sudo wget http://poweriso.com/poweriso-1.1.tar.gz

Extract it like so:

sudo tar -zxvf poweriso-1.1.tar.gz

Then convert like so:

./poweriso convert /folder/file.daa -o file.iso -ot iso


Substitute your file and folder names for the above.

Job done!
add comment   |  permalink   |   ( 0 / 0 )
Finding which hardware you've got 
Friday, December 28, 2007, 16:27
Posted by Administrator
Let's say you need to list all your current hardware, or maybe you just need to know what type of network card you got? Easy!

sudo lshw


this will simply list all your hardware. If there is way too much to take in and it scrolls off you can do one of two things, either this:
sudo lshw >> /home/yourname/hardware.log
vim /home/yourname/hardware.log

This will shove the output into a file called hardware.log in your home directory which you can then view with vim or your favourite text editor.
On the other land, let's say you only need to know what network card you have. You can do it like so:
sudo lshw -C Network

This command will simply only display the network part of the output. Change network to whatever you need to see.


add comment   |  permalink   |   ( 0 / 0 )
Check folder size 
Thursday, December 13, 2007, 15:12
Posted by Administrator
Need a quick way to check the size of any folder from the terminal?

du -hs /folder/


-h will show it in human readable format as opposed to block size, and -s will give you a summary.
add comment   |  permalink   |   ( 0 / 0 )

| 1 | 2 | 3 | 4 | 5 | Next> Last>>