COOKIES! This blog uses cookies!
I am completely out of control of cookies here, otherwise I would have disabled them (it is controlled by the platform).
If you don't like cookies and being tracked please leave this blog immediately.

Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Friday, 7 April 2017

Windows Creators Update and compatibility of Linux subsystem with Windows binaries

Windows 10 “Creators Update” is finally available to install outside from “insiders programme”, it will soon land on most of windows 10 machine, and those who impatient can install it directly from the website: https://www.microsoft.com/en-us/software-download/windows10

Most valuable thing in this update for me is update of linux subsystem to the Ubuntu 16 and compatibility of this subsystem with Windows binaries, so you now can call pretty much any windows binary from the windows bash. (it is available in build Builds above 14951)


Unfortunately the update of subsystem is not 100% smooth, the subsystem has to be installed and re-installed back (hopefully will not be required soon).


  • (option for impatient) download “Update Now” from the https://www.microsoft.com/en-us/software-download/windows10 and install the update, the system will restart a few times.
  • After update is installed open “bash” and do “lsb_release -a” to check that you’re still on Ubuntu 14;
  • Backup any files and config from the subsystem, for example copy your ~/.bashrc to outside of the subsystem with `cp ~/.bashrc /mnt/c/temp/`
  • Exit the bash and go to windows cmd
  • Uninstall subsystem with `lxrun /uninstall`
  • Re-install linux subsystem with `lxrun /install`
  • Go to the `bash`
  • Ensure that it is now Ubuntu 16 with `lsb_release -a`
  • Try running Windows binary from the bash for example `/mnt/c/Windows/System32/ipconfig.exe /all`

This ability to seamlessly run windows binaries gives many useful opportunities, for example controlling VirtualBox virtual machines from vagrant running inside of linux subsystem.

Friday, 16 May 2014

copy all GIT diff files on windows

Windows CMD one-line command to copy difference of two GIT commits into specific directory preserving directories hierarchy:

git diff --name-only yrc0m1 yrc0m2|sed s:/:\\:g > report.txt && for /F %F in ('cat report.txt') do xcopy %F c:\m1m2diff\%F && del report.txt

*xcopy will ask you to confirm wither the path is file or directory for each of your changed files. As far as diff returns only files changed, you can just do long F button press :-) Unfortunately I did not succeed to find a flag to suppress this warning with F option.

It consists of following subcommands:
1. git diff --name-only yrc0m1 yrc0m2 - returns list of changed files between commits yrc0m1 and yrc0m2;
2. sed s:/:\\:g - piped with | after previous one, converting Linux slashes to windows slashes;
3. > report.txt - oputput of previous two commands: all relative filepaths are saved in report.txt;
4. for /F %F in ('cat report.txt') do xcopy %F c:\m1m2diff\%F - iterates through lines in report.txt and copying file creating all not-existing directories from it's relative path (we suppose that c:\m1m2diff\ directory already exists)
5. del report.txt - simply deletes report.txt file.

Tuesday, 29 April 2014

Running python along with PHP on Windows with Apache

Short howto:

1. Install Python on the server or your computer (adding Python.exe to the path)

2. download pre-compiled mod_wsgi.so from:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
You should download right file for your Apache version and for your Python wersion:
for example mod_wsgi‑3.4.ap24.win32‑py3.4.zip is mod_wsgi.so for Apache 2.4 compiled as 32bit app and Python 3.4. This file works fine for me on XAMPP 1.8.0

3. Extract mod_wsgi.so into your /apache/modules/ directory (would be C:\xampp\apache\modules for XAMPP)

4. Add the following string into your /apache/conf/httpd.conf (somewhere among others LoadModule strings):
LoadModule wsgi_module modules/mod_wsgi.so

5. Say you want your Python stuff to work on URL http://localhost/my-python-stuff/:
Create /my-python-stuff/ directory inside of your localhost's public_html dir (/htdocs/localhost/www/ for XAMPP);
Create .htaccess and index.wsgi files in this directory;

.htaccess
Options +ExecCGI AddDefaultCharset utf-8  #add wsgi handler AddHandler wsgi-script .wsgi  #redirect all requests to index.wsgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.wsgi/$1
index.wsgi
def application(environ, start_response): status = '200 OK' output = 'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
Now if you re-start/run your apache/XAMPP and open http://localhost/my-python-stuff/ , or any other URL deeper than /my-python-stuff/ (/my-python-stuff/test/ and so on), you will see Hello World message in your browser.