Suppose this very common situation: you have two machines, A and B. You have some files on A and you want to transfer those files to B. Let's assume you don't have ftp server, samba, nfs or anything similar which could make this operation trivial. If talking about home/desktop computers, this is a most common situation.
Although it's possible to transfer files by using scp/sftp, netcat or something else, today I saw a very cool trick which comes handy in such situations. All you need is Python.
First, change your current working directory to the directory that holds files you want to share. Then, just run this command:
Although it's possible to transfer files by using scp/sftp, netcat or something else, today I saw a very cool trick which comes handy in such situations. All you need is Python.
First, change your current working directory to the directory that holds files you want to share. Then, just run this command:
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
This will run web server or port 8000 which you can use to browse and download files, on a similar way like using file://directory in your favorite browser or viewing web pages without index.html. When you are done, just press CTRL+C.
2 comments:
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()" 31337
To listen on other port...
This is one of those simple things that will make my life easier. Thank you for the post.
Post a Comment