Remotely download files using ssh,wget & scp

Below is a script I wrote so that I can download ISO’s using wget at the university. Just using wget from my machine fails because the proxy has issues with files over a certain size (I think? anyone confirm this too?). I would usually just download them using the browser… but wget is far more reliable… plus you can pause and resume downloads, and it actually *works*!

Ok, the script wgetremote:

#!/bin/bash
# Download file on remote host
# and then copy file to machine and delete file from remote host
# means you can download larger files more easily (e.g. ISO's)

# Requirements: ssh, scp, basename, sed

if [ $# != 3 ]
then
# No Arguments Passed
echo -e "error: incorrect arguments given\nusage: wgetremote [user@remotehost] [URL] [destination]"
else
# Main
location=$1
url=$2
dest=`echo $3 | sed 's/\/$//'` # remove last /
fn=`basename $2`

# Download,copy and rm
ssh $location "wget $2"
scp $location:$fn $dest
ssh $location "rm $fn"
echo "Saved file: $dest/$fn"
fi

Also too, if you have a scripts dir in home then add it to the path in Ubuntu by adding this to .bashrc (yes I know it shouldn’t really go here… but adding this to .profile wasn’t working in Ubuntu for some odd reason):

# add scripts dir if exists
if [ -d "$HOME/scripts" ] ; then
    PATH="$HOME/scripts:$PATH"
fi

Also, anyone know a nice way to access ext2/3 partitions in Windows? I can access Windows files in Ubuntu (since i’m using wubi there just in /host) but I’d like to access my Linux files in Windows. Or maybe i’ll just write a folder sync script and run it at logout. If anyone knows feel free to leave me a comment! Alex.

Compiling uemacs on Ubuntu

Recently I started learning emacs, but since emacs can still be quite slow to startup even on a modern system I started to look for fast emacs versions, or emacs clones. I tried jove, zile, mg and a couple of others when I stumbled across the wiki page for MicroEMACS. I’ve used MicroEMACS before since it comes bundled with the default AmigaOS versions, and i’d heard that Linus Torvalds used a custom version too, so since I was bored I thought it was worth a try… thinking it was just going to be a simple download and make I headed over to the download site: http://www.kernel.org/pub/software/editors/uemacs/

How wrong I was… about 1/2 an hour later I got it to build, and i’m documenting the steps below incase anyone else wants to try the editor.

In all honesty though, I wouldn’t bother, zile or jove are much better emacs clones, also worth a try is mg, but uemacs isn’t worth it, since the default keybindings aren’t correct and there isn’t an easy way to change them even in the config (from what I can tell, feel free to leave me a comment).

But, if you’re still interested, here goes:

How to compile uemacs from source on Ubuntu
===========================================
* Note: you may need to have build-essential installed for this tutorial to work

1. Download em-4.0.15-lt.tar.gz or em-4.0.15-lt.tar.bz2 from
http://www.kernel.org/pub/software/editors/uemacs/ and extract

2. Change to em-4.0.15-lt directory

3. Run: cp makefile.unx makefile

4. Make the following changes:

	in makefile:

	* add -include /usr/include/errno.h to line 17
	* change lines 27 and 28 to BINDIR=/usr/bin LIBDIR=/usr/lib respectively

	in main.c:

	* change line 126 from static void... to extern void
	* change line 602 from static void... to extern void

5. Now type make

6. Ignore all the errors, and if you ls you should find an emacs binary in the directory,
to run it type ./emacs (now you can make install if you really like uemacs...)

7. Now realise how bad uemacs is, and use normal emacs, or try mini-emacs like editors
such as zile ;-D

Hope that helps at least someone… I couldn’t find any real help on building uemacs anywhere, so hopefully someone finds this helpful!

But yeah, really anything is better than uemacs… maybe even (gulp) vi! ;-D

Fluxbox theme

This theme:

http://customize.org/fluxbox/themes/39619

Then:

*Font:                          Bitstream Vera Sans:pixelsize=11 (Line 79)

window.label.focus.textColor:   #ffffff 			 (Line 28)

Fluxbox background in Ubuntu

Set background in fluxbox, need:

sudo apt-get install xloadimage

Then:

xsetbg /home/alex/Pictures/Wallpaper/01881_orionnebula_1680x1050.jpg

or

fbsetbg -f /home/alex/Pictures/Wallpaper/01881_orionnebula_1680x1050.jpg

~/.fluxbox/startup

# set background
fbsetbg -f /home/alex/Pictures/Wallpaper/01881_orionnebula_1680x1050.jpg

# And last but not least we start fluxbox.
# Because it is the last app you have to run it with ''exec'' before it.
exec fluxbox

Linux sysinfo

Just a small script to show system name, processor info and memory info all in one:

#!/bin/bash
uname -a &&  cat /proc/cpuinfo | head -8 && cat /proc/meminfo | head -5

Some basics…

Some basics that are probably worth noting here:

GCC Configuration:
./configure --prefix=/path_to_install_dir

Search for available app to install:
apt-cache search app_name

Update and fix missing sources and agree to all:
sudo apt-get update --fix-missing --force-yes

Uni proxy:
http://www.robgolding.com/index.php/2008/11/24/ubuntu-and-the-university-of-nottinghams-proxy/
128.243.253.119:8080
http://wwwcache.nottingham.ac.uk/proxy.pac

/etc/bash.bashrc:
export http_proxy=128.243.253.119:8080

(Non-ubuntu or without Gnome network proxy manager)
/etc/environment:
export http_proxy=128.243.253.119:8080

Misc:
vim-full (for Ubuntu)
ubuntu-restricted-extras

(BTW, this blog is mainly for myself to note stuff down, if anyone finds it useful then good, but sorry for the terseness, again its just for noting stuff…!)

Edit fluxbox options

Fluxbox options are in .fluxbox in your /home/$USER directory.

Key: Description (file)

Change theme (init):
session.styleFile:	/usr/share/fluxbox/styles/bora_black

Wifi Manager (startup):
...
# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.
#
# unclutter -idle 2 &
# wmnd &
# wmsmixer -w &
# idesk &

# start network manager for Wifi
nm-applet &
...

Change doubleclick titlebar action to Maximize (keys):
(but leave original shade option too)

# double click on the titlebar to shade
#OnTitlebar Double Mouse1 :Shade

# double click on the titlebar to Maximize
OnTitlebar Double Mouse1 :Maximize

Download latest chrome for Linux script

Quick script to download the latest version of Google Chrome/Chromium for Linux, requires wget and zip/unzip, first the get-chrome.sh script:

#!/bin/bash
# get-chrome.sh
# Get latest build of Google Chrome for Linux
# 21 June 2009
# NOTE: requires wget, unzip

rm chrome-linux.zip*
wget http://build.chromium.org/buildbot/snapshots/chromium-rel-linux/LATEST
latest=`cat LATEST`
rm LATEST
wget http://build.chromium.org/buildbot/snapshots/chromium-rel-linux/$latest/chrome-linux.zip
unzip -o chrome-linux.zip

Next, the run-chrome.sh script:

#!/bin/bash
# run-chrome.sh
# Run latest build of Google Chrome for Linux
# 21 June 2009

cd chrome-linux
./chrome&

Enjoy!