Archive

Author Archive

Specifying a JVM for applications that don’t ask

February 26th, 2008 admin No comments

Some programs (ie. Eclipse) will ask you which JVM you want to use in the event that you have multiple. Other programs will just scrape your PATH for the first Java binary.

Say you want to run Azureus with Java 6 but you don’t want to install the JRE from Ubuntu repositories.

  1. Download the JRE binaries from http://java.sun.com ( or whatever JRE you want )
  2. Download an application that requires a JRE
  3. Run the following in your terminal:
    (PATH=/path/to/your/java/executable:$PATH && \ /path/to/the/app/to/run)
  4. Make sure to wrap you command in parentheses!

What’s happening here is:

  1. You are prepending the location of the new JRE to your current PATH variable
  2. If that was successful, you are executing your application. If not, then your application won’t be started
  3. All of this is done within a set of parentheses. This runs everything in a subshell. When you exit the application, your regular PATH variable is untouched.
Categories: Ubuntu Tags: , , ,

The closest thing to piping a password to SSH

February 26th, 2008 admin No comments

There are a few cases in life where you want to connect to SSH without having to type in the password by hand. Most of the times you can use ssh-keygen and use private (or public) keys.

However, for the 0.5% of the time where you cannot use keys, you can use a little program called expect.

BTW, this does not, and should NEVER work:
echo 'mypassword' | ssh user@server

Installing Expect:
sudo apt-get install expect

Create the expect script:
nano connect.sh

Paste the basic code:

#!/usr/bin/expect
set timeout 60
spawn ssh -l username server
expect "password: $"
send "password\n"
expect "$ $"
interact

Replace ‘username’ and ’server’ on line 3 and ‘password’ on line 5.
The second to last line, ‘expect “$ $”‘ is for a bash shell. Replace the first ‘$’ with whatever your prompt is.

Save ( ctrl + o ) and Exit ( ctrl + x )
Make the script executable
chmod +x connect.sh

Credits

Categories: System Admin, Ubuntu Tags:

Bringing back wireless after suspend in Ubuntu Gusty

February 24th, 2008 admin No comments

It’s true that some features of Linux aren’t quite as reliable as their Windows counterparts. For me one of those “nice to have but not totally necessary” features has been Suspend and Hibernate. In the past, I’ve had experiences where either the OS just hangs or never wakes up. However, my new experience is that (with Ubuntu Gusty (7.10)) everything comes back from Suspend or Hibernate EXCEPT my wireless interface. If you’re like me (and everyone else on the planet) your wireless connection is vital.

After some searching on Ubuntu’s launchpad, I found the answer:

Open /etc/default/acpi-support

sudo nano /etc/default/acpi-support

Add networking to the STOP_SERVICES. For me it was on line 61.

Before

# Add services to this list to stop them before suspend and restart them in
# the resume process.
STOP_SERVICES="mysql"

After

# Add services to this list to stop them before suspend and restart them in
# the resume process.
STOP_SERVICES="mysql networking"

Your wireless should now come back after Suspend / Hibernate.

Categories: Ubuntu Tags: