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.
As usual, you may need to point to bash.exe full path.
I tried, didn’t work.
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 see the same here.
I bet there is going to be some OLE way of doing this…
Try to start your app as admin. But no i dont tried in xojo, the shell got so many problems on windows with… for aexample some java comands dont work really, maybe this is a problem too.
maybe you try it with a vbe
ws.run "C:\\Windows\\System32\\bash.exe -c 'sudo /usr/sbin/sshd -D -p 2222'",0
You are suggesting I run this through Shell.Execute?
maybe you write a run.vbe with this and try to shell.execute this cant test it by my self cause i have linux sub only on my NAS for nextcloud
Thanks, I’ll keep experimenting.
Try executing cmd.exe and then running your bash script
Shell ? cmd.exe instance
Would I need to do this though an Interactive Shell, or is there another way? I tried
cmd.exe /C /path/to/bash etc with the same result.
probably an interactive shell
Same result, unfortunately.
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:
[code]bash -c /mnt/d/VPS-Backup/BackupScript.sh
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.
When I installed bash, it required to create a login and password. Would it be possible that calling bash from another place than Command Prompt did require login in ?
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 Lefebvre 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?