Using powershell on win10 to invoke bash

Hi Guys,

I am trying to run flyway command on ubuntu.

on windows command line is simple :

C:\Users\admin\Downloads\flyway-commandline-5.0.7-windows-x64\flyway-5.0.7> flyway migrate

how can i do it via bash?

i tied to use mnt command but starting flyway is not possible.

Please help,
Jacek

Is this the Flyway database migration tool? Are you attempting to run it in an Ubuntu subsystem on Windows, or from a separate Linux machine? If you are using a separate machine you should download and install Flyway for Linux.

Andrew

Hi Andrew,

thank you!
YEs, flyway is a database migration tool.

exactly this one

Best,
Jacek

To start with, I know nothing about Windows 10 or the linux sub-system. But according to this how-to geek article you need the Creator's update or later to run Windows apps from bash, but you knew that already.

Have you tried cd'ing into the flyway directory and running it from there, as you did in your example using it from the command prompt? Remember that (1) bash is case-sensitive and (2) you will have to prefix the command with ./ as in

./flyway migrate

Andrew

Hi Andrew,

cd is not working within bash, how can i do it?

Best,
Jacek

cd /mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7

does not work? What is the error?
Please don't just say "xxx does not work". Instead you should paste into your posting the command you type and the response (in code tags, of course).

Andrew

1 Like

Thank you Andrew!

cd /mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7

Working !

But when i am within this folder and trying to run flyway.cmd
using code:

./flyway migrate

there is an error:
line 62: java command not found

i think that still here is a problem with running flyway command line from bash...

Best,
Jacek

From your command prompt, type

echo %path%

and from your bash shell type

echo $PATH

and paste the results here.

Please use CODE tags, not ICODE tags.

Andrew

Hi Andrew,

Here is the code:

root@admin-Komputer:/mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7# echo %path%
%path%
root@admin-Komputer:/mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/ProgramData/Oracle/Java/javapath_target_79965703:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files/PostgreSQL/10/bin:/mnt/c/Program Files (x86)/Windows Live/Shared:/mnt/c/Users/admin/AppData/Local/Microsoft/WindowsApps:/snap/bin
root@admin-Komputer:/mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7#

Best,
Jacek

The first one should have been from your windows command prompt; it will give the executable path for windows programs.

Andrew

What do you mean Andrew?

So my Path is not working correctly?

Jacek

I meant for you to run the

echo %path%

from your Windows Command Prompt, also referred to as the "DOS Box", started from the Start Menu as CMD.EXE. Not the Power Shell, and not Bash.

I wanted to compare that path with the bash $PATH and see if I could spot where the java executable is, so I could advise you on how to adjust the bash $PATH.

Andrew

1 Like

Ok here is the code from windows cmd:

C:\Users\admin\Downloads\flyway-commandline-5.0.7-windows-x64\flyway-5.0.7>echo %path%
C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\PuTTY\;C:\Program Files\PostgreSQL\10\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;

Best,
Jacek

---------- Post updated 03-13-18 at 03:21 AM ---------- Previous update was 03-12-18 at 10:02 AM ----------

Anyone?

Jacek

Not implying any deeper knowledge of the subject on my side, what catches my eyes is the discrepancy between the java paths:
/mnt/c/ProgramData/Oracle/Java/javapath_target_79965703 vs C:\ProgramData\Oracle\Java\javapath

okey thank you. So problem can be here that bash script has no java in correct place.

How can i set up path for this correctly? (i do not have idea).

Best,
Jacek

Is /mnt/c/ProgramData/Oracle/Java/javapath_target_79965703 a valid path, i.e. does this directory exist and contain any executables?

For just testing, you could add the additional path:

PATH=/mnt/c/ProgramData/Oracle/Java/javapath:$PATH

and mayhap export it. Should this work, you may want to make it persistent, probably by modifying your login ~.profile or ~.bashrc file, either adding the valid path, or correcting the wrong one.

Hi RudiC,

thank you!

Here you can find image what is in my folder:
link

added this path within bash command line. Nothing happend:

root@admin-Komputer:/mnt/c/Users/admin# PATH=/mnt/c/ProgramData/Oracle/Java/javapath:$PATH

still flyway migrate doesnt work.

Best,
Jacek

see post#6.

I see, i went to this folder using cd command:

PS C:\Users\admin> bash
root@admin-Komputer:/mnt/c/Users/admin# cd /mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7
root@admin-Komputer:/mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7# PATH=/mnt/c/ProgramData/Oracle/Java/javapath:$PATH
root@admin-Komputer:/mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7# flyway migrate
flyway: command not found
root@admin-Komputer:/mnt/c/Users/admin/Downloads/flyway-commandline-5.0.7-windows-x64/flyway-5.0.7# ./flyway migrate
./flyway: line 62: java: command not found

Best wishes,
Jacek

OK - WHERE is the java command? Add the relevant path.

1 Like