View Single Post
Posts: 230 | Thanked: 302 times | Joined on Oct 2009 @ Helsinki, Suomi (Finland)
#2
I'll start with a script called "httpshare" which I made to ease sharing files on my N9. It's basically just a helper script for Python's SimpleHTTPServer, but I've found it very useful when I need to quickly access contents of my N9 from another device.

See/Get it here.

Screenshots for impatient:



Installation:
It depends on python so you need to:
Code:
# apt-get install python
Copy the script to your ~/bin (or elsewhere inside your user's $PATH) and give it executable permissions:
Code:
$ chmod 755 ~/bin/httpshare
Usage examples:
Code:
$ httpshare .
$ httpshare ~/MyDocs/Movies
$ httpshare /etc
On the client side, open a web browser and navigate to N9's IP address.

If you want to access the server from WAN (internet) remember to set your router's port forwarding accordingly.

On a mobile "broadband" (2G/3G) it's possible that your ISP uses NAT for IP addresses (your device doesn't have a public IP address) or the port 80 (http) for incoming traffic is blocked. In latter case you might be able to get through using some other port. (set the value of port variable in the script accordingly).

Known issues:
-Python SimpleHTTPServer will spit out some garbage on keyboard interrupt (Ctrl+c). This is harmless other than aesthetically. I didn't find a good way to remove the garbage as it seems to lump almost all of it's output into stderr and thus sending 2 > /dev/null will also get rid of useful output, such as info on incoming connections. If you nonetheless want to make it quiet you can redirect all it's output to /dev/null by replacing the line:
Code:
develsh -c "python -m SimpleHTTPServer $port > /dev/null"
with:
Code:
develsh -c "python -m SimpleHTTPServer $port > /dev/null 2>&1"
-On Harmattan you need to exit using Ctrl+c. Simply closing the parent terminal won't kill the server. This is probably caused by having develsh inside the script to enable access to port 80 for user. (I didn't notice the same behaviour when running the script sans develsh on a linux desktop.)

PS. Code tags on TMO don't work (wrapping of lines), otherwise I would have posted the script into message itself.

Last edited by ladoga; 2013-01-01 at 19:32.
 

The Following 8 Users Say Thank You to ladoga For This Useful Post: