Is there some trick that will allow me to run bash script in Windows through the Shell or otherwise? The commands that work in the DOS prompt ("bash shellscript.sh") tells me bash is not recognized when run through Shell.
bash is only available if you installed linux subsystem. Then you can use this for example: bash.exe -c sudo "/etc/init.d/apache2 start"
The example will start apache and close it immediately, cause the bash doesnt keep it open. But it should help you to start a script.
Thanks Sascha, but have you tried this using the Xojo Shell? That's where I'm having trouble as the same commands that work on the DOS prompt fail in Shell with...
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command, operable program or batch file.
I use the bash shell on Windows to back up my VPS using rsync. A batch file called "Run backup script.bat" contains the following:
bash -c /mnt/d/VPS-Backup/BackupScript.sh pause
And (sorry, no solution here!) I've run into what I suspect is a related problem. What I'd like to do is run the batch file using Windows' Task Scheduler so that I can have regular unattended backups. But when launched from Task Scheduler it just plain doesn't run - same as you're getting. I spent a lot of time Googling around for possible solutions for this and came up blank. The best workaround I came up with was to use Task Scheduler to run the script when I log on to the computer. That works.
As far as I can see, there's something that's available when the script is launched by a user that isn't available when it's launched from elsewhere, even if the same user credentials are used.
Would love to find a solution to this - right now I've got my fingers crossed for the next release of Windows 10, allegedly due in March/April.
That's a good point, maybe it is something to do with the "Default UNIX User Account". There's more info on that here: https://msdn.microsoft.com/en-us/commandline/wsl/user_support .
I'm away from my main Windows 10 machine at the moment, so can't test, but Kem - did you try Sasha's suggestion of right-clicking on your Xojo app and choosing "Run as Administrator" to run it with elevated permissions?
@Paul L and I did some digging and may have come up with a reason, but not a solution. bash requires 64-bit, but Shell in a 32-bit app is in ... well, 32-bit, and can't access bash. Running as 64-bit gets further but we didn't pursue that very far.
So now the question is, can we access a 64-bit command processor from a 32-bit app?