Have to admit it – this happens every time I sit down to write a some shell script that manipulates paths on windows (where path names often end up with spaces). Soon I find my nifty little script running into problems when it doesn’t handle spaces properly and I find myself reading up on bash quoting rules once again…
Anyway, so this post is mostly for self reference and to put down some simple rules in the hope that writing it down will help committing it to memory.
The latest (mis)adventure was to make irfanview run under wine and a little script to allow irfanview to open a file provided on the command line. Irfanview being a windoze executable, its necessary to cd to the folder and then pass the file as argument to irfanview. Trivial isn’t it….until I found that the script fell over when it got a path liek /path/to/a folder with spaces/image.jpeg.
DIRNAME=$(dirname “$1″) # double quotes necessary – since $1 could have embedded spaces
cd “$DIRNAME” # once more, double quotes necessart
When passing a path as argument, always enclose in double quotes.
I’m having weird problems with firefox 3b2 on ubuntu gutsy – and as far as I can tell, I seem to be the only one. Did not find anything similar on ubuntu forums too.
Installed firefox 3 beta 2 from Mozilla to /usr/lib/firefox3b2 folder and created
lrwxrwxrwx 1 root root 27 2007-12-30 23:44 /usr/bin/firefox-3b2 -> /usr/lib/firefox3b2/firefox
When I launch firefox3b2, I get firefox alright, however, in the location bar if I type in a url and press Enter, nothing happens – absolutely nothing at all. I have to go and click the green arrow for the browser to open the URL. The search box is even weirder – neither the Enter key works nor does the mouse!
I’m at a loss – and nor can I find any similar experiences on forums etc – ideas welcome
SOLVED 01/20:Backed up my .mozilla folder and started firefox 3 b2 – no problems now
For machines to be accessible on the internet, usually you need a static IP that’s leased from your ISP so that when someone types in your IP address, so that packets can be routed over to your machine. However, getting a static ip is costly and for the most part, internet users have dynamic IP address that the ISP allocates each time an end user connects to the internet. Since the ip address keeps changing on each connection, there’s no straightforward way to connect to the machine without knowing the IP address that’s been allocated – or so it was at least till Dynamic DNS came along (it isnt new – has been around for ages, but for some reason isn’t that well known)
Typically, when you type in http://www.google.com in your browser, your machine performs a DNS (Domain name service) lookup with the DNS servers from your ISP to find out the IP address corresponding to http://www.google.com. With DDNS (dynamic DNS) this is made to work with your dynamically allocated IP address also. Here’s how it works
- Register with a DDNS service provider. Service provider provide free accounts for personal use – go to www.dyndns.org
- Once you’ve created your account, go ahead and set up your hostname. DDNS service providers will have some domains that you can choose from and you get to choose the host part. For a fee, you can also use a domain name of your choice.
- If your set up has a router at your end, check your router administration page if it supports dynamic DNS. If it does, you need to enter the hostname, account and password. Everytime your router connects to the internet, it sends an update notification to the DDNS service notifying the new IP obtained from your ISP. The DDNS service takes care of sending update notifications to routers on the internet.
- If you dont have a router, then download the DDNS client software from the service provider. Most DDNS providers have windows, mac and linux clients. These run on your machine and do the same thing – notify the DDNS service provider of your new IP whenever you establish a connection with your ISP.
- If you’ve got all this set up, then you can reach your machine from the net – try ping <your host name>
If you’re running Linux/Ubuntu, make sure your’re running SSH service and try ssh <your host name>. If you have a router setup, then you will need an additional step – basically the DDNS name refers to your router IP – and not the machine behind the router that you wish to reach. You will also need to make sure that your machine has a static IP from your router. To set up your router, go to your router administration page.
- Go to the LAN section and give a range of IPs outside of the static IP. Most routers have lan addresses like 192.168.x.y – 192.168.x.z. If you want your host to have an IP address of 192.168.1.100, then give a LAN range that does not include this IP – say 192.168.1.110 – 192.168.1.200.
- Save and reboot your router.
- Now go to your network settings and enter your static IP (192.168.1.100), netmask 255.255.255.255, gateway (usually 192.168.1.1).
- Go to your router administration page and look for a section like virtual server – your router will allow you to forward packets received on a particular port to a host and port within your LAN. You will have to enter the external port (we’ll use 22), the internal machine to forward (192.168.1.100) and the port to forward to (22). With this in place, any packets received on port 22 (ssh) on your router will be forwarded to the 192.168.1.100 machine on the ssh port.
- Save and reboot your router.
- Give it a spin.
From a different machine (or from the same one -doesnt matter), try out ssh <your host> and you should be able to login to your machine – via the internet.
I’m on vacation in Bangalore, and guess what – fixing my home computer. Mostly things like lost drivers, screen resolution, cruft in the drives – its an old machine – a P4/512 Meg, but good enough for surfing the net.
Did a few fun things in the midst, and its been ages since I’ve added anything to this blog. Will summarize for now and put in longer posts with more details in cases someone’s interested.
- Fixed my windows C drive which was running out of space – used trusty old windirstat for that.
- Set up wifi at home with ADSL modem from BSNL – MT800. Again, wasn’t as straightforward as I’d thought.
- Replaced old pcq linux 2006 with ubuntu gutsy – without losing stuff :D. Need to have /home in a separate partition, but otherwise this is a breeze.
- Having fun with compiz-fusion. Its great – however, the documentation isnt easily locatable/consumable enough for first timers (me).
- Set up DNS caching proxy on my linux box – has improved my net/web experience a 100 fold. Was a piece of cake too.
- Set up Dynamic DNS and remote SSH access to my box – this has been the single most important utility/maintainance action.