Use bash shell with wamp on windows - windows

I'm working on local website hosting by WAMP and i'm trying to execute bash command with exec or system functions but it only works with cmd or powershell command cause i'm on windows.
Is there a way to force bash interpretation ?
Thank you.

Related

Why is $OSTYPE returning "linux-gnu" on Windows?

Problem
When I run a bash script on Windows:
bash my_script.sh
I get linux-gnu for $OSTYPE inside the script.
Why is this like this?
I assume that i have WSL installed is relevant here.
Tested in PowerShell and CMD.
Git bash is returning msys like expected! Thx #user1934428
Background
I want to start some python scripts from bash, but not inside WSL.
From my command line I reach different python versions on windows, but from inside the bash scripts it is using the one inside WSL (except for GitBash).
You're right, running the bash command in PowerShell or CMD will launch WSL to run your script. You confirm this (and see which version of WSL) by running cat /etc/issue in your bash script. Your WSL environment will have an independent set of environment variables (not just $OSTYPE). You can see this by comparing the output of Get-ChildItem -Path Env:\ in PowerShell to the output of env (after you launch bash from PowerShell).
I suspect that the python version discrepancy you're seeing is a result of the PATH variable in your WSL runtime not matching what you have set in your PowerShell environment. You can fix your version issue by setting an alias containing a path to the python executable you want to use by adding alias python=/c/path/to/python.exe to the start of your bash scripts.
Alternatively, you can use a tool like Cygwin or git-bash to run your scripts. I'm not sure if they will use the same path variables as Windows so you may need to set those manually too.

How do i access AWS SAM-CLI through bash on windows?

I am running Windows 10 and can only access AWS SAM through command prompt but not bash. When i try to use bash, i get a bash: sam: command not found error.
If it helps, I currently have installed AWS CLI v2 and have installed it via an MSI file.
Why am i not able to use SAM through bash?
Edit: Yes i am aware that it doesnt explicitly say that you can use bash on the AWS setup guide
Verify the installation.
After completing the installation, verify it by opening a new command prompt or PowerShell prompt. You should be able to invoke sam from the command line.
However, I still want to be able to use it through bash. Is there a workaround?
Do you tried sam.cmd?
Sometimes bash don't know how to execute .cmd files. Here is a thread with this problem.
You can try this solution too:
alias sam='sam.cmd'

How would I interface with the Linux terminal (bash for windows) using windows command prompt?

I just recently found out about using bash in windows. I had alot of fun installing linux programs onto my windows computer using bash and wondered how I would be able to run an automatic script so I dont have to export my display everytime I open bash.
I used to write scripts for cmd called batch scripting and I would be able to do everything cmd could do. Now that I have access to bash, I want to script a program that connects useful pieces of cmd with useful pieces of bash but I Can't find any results telling me how to call bash commands from cmd. Thank you - Zak Kaioken

Run the shell commands in Perl using system() function in Windows

I am migrating some plugin from Linux to Windows.
Plugin is written using Perl and it has the function called system() that will execute the shell commands.
But I am migrating to Windows now. Any way I can run the linux command in windows using system() Per function?
Some Perl Module avail for this ?
You can run the system() command but there are caveats. A nice description is contained in Using system or exec safely on Windows. This article resulted in the Win32::ShellQuote module.
You want to run a linux command vie Perl in a windows shell? If so, try a Linux environment like Cygwin (www.cygwin.com). Otherwise you have to migrate your system calls as well.

Run a shell script on Windows - Drupal install using DAMP

i've installed DAMP on Windows Vista, and have created a profile in my drupal folder with a shell script that needs to run.
profiles/donor_rally/rebuild.sh
However, I don't know how to execute this shell script.
I am not familiar with shell script command language, would you be willing to provide me with a step-by-step instructions on how to execute this shell script?
Thanks.
It looks like you're trying to run a Bourne shell script, which would usually only run on a unix machine. Guessing from the name, this is supposed to rebuild something, likely the database, but that's just a guess.
The short answer is you can't run it, at least not easily. If you were to post the (edited) contents of the script you might get some answers about how you could port it to a Windows cscript or batch file.
For others who are uninitiated to shell scripting in Windows:
I did not find a straightforward solution for running shell scripts on AMP hosted on Windows.
Instead I got an account at webenabled.com
Then used PuTTy to tunnel in.
I found this guide to using UNIX: http://freeengineer.org/learnUNIXin10minutes.html
And lynda.com

Resources