Main Menu

friends

Latest articles

How to find files in Linux
02/08/2009 | mad mad mod

This article describes how to find files in Linux. locateThe fastest way to find a file on Linux is by using the "locate" command. If you know the name of the file or just a part of the name you  [ ... ]


Installing VirtualBox on Linux (Fedora)
10/10/2009 | mad mad mod

If you want to run windows application on Linux, you have several options:use wineInstall Windows in a XEN VM (with full virtualization) Install Windows on a VMWare VM (Server or Player)Install Windo [ ... ]


Other Articles
Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 

Designed by:
SiteGround web hosting Joomla Templates
How to automatically start Windows XP in VirtualBox when plugging in the iPhone on Linux E-mail
VirtualBox

How to automatically start Windows XP in VirtualBox when plugging in the iPhone on Linux

 

 

1.The shell script

 

Create a script in /usr/local/bin/ to start your Windows XP machine in VirtualBox. I will name it "vbox.sh". Now open the file with vi:

 

# vi /usr/local/bin/vbox.sh

 

Copy paste the following code into the file:

 

#!/bin/bash
source /etc/profile


#which user is logged in now?
u=$(who|head -n1|sed s/" .*"//)

# set the DISPLAY to :0.0

export DISPLAY=:0.0

 

# now, switch to the logged on user and run "xhost":
su - $u -c"xhost local:$u"

 

# is VirtualBox already running?
running=$(ps -ef|grep VirtualBox|grep -v grep |wc -l)

 

# if it is not running then start the XP machine:

if ( expr $running = 0 )
then
/usr/bin/VirtualBox --startvm xp
fi

 

replace xp with the name of your Windows XP machine.

 

Ok, now save the file and make it executable:

 

# chmod 700 /usr/local/bin/vbox.sh

 

2. The udev rule

 

create a file in /etc/udev/rules.d/ to define the rule. I will name the file 10-iphone.rules. Now open the file with vi:

vi /etc/udev/rules.d/10-iphone.rules

 

Copy paste the following code into the file:

KERNEL=="usbdev*.*_ep00" SUBSYSTEM=="usb_endpoint", ATTRS{serial}=="98u3498jd9832dj98323874938ue938479238ue" ATTRS{product}=="iPhone" ACTION=="add", RUN="/usr/local/bin/vbox.sh"

 

explanation

 

 

KERNEL=="usbdev*.*_ep00"

--> The iPhone device file is usually something like /dev/usbdev1.3_ep00

 

 

ATTRS{serial}=="98u3498jd9832dj98323874938ue938479238ue"

--> VirtualBox should only start up when I plug in MY iPhone. Just replace the serial number with the one from your iPhone. If you don't know your serial number, you can run the following command:

udevinfo -a -p $(udevinfo -q path -n /dev/usbdev1.3_ep00)

(replace usbdev1.3_ep00 with the name of your device)

 

ACTION=="add"

--> don't start VirtualBox when we plug out the iPhone

 

RUN="/usr/local/bin/vbox.sh"

-->run the script

 

I think thats it! I am not sure if thats the best way to do it. So, any suggestions are welcome!

 

 

 

 

 

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting