I have a bash script that runs screen and uses $( command ) to execute the output of command. I need to port this script to run on Windows. I installed Cygwin to run this but it doesn't recognize screen as a command and I don't know the Windows equivalent of linux's $(). Any suggestions on how to do this in windows?
screen is not installed by default.
You need to explicitly install it using cygwin setup.
https://cygwin.com/faq.html#faq.setup.what-packages
$( command ) it is available in bash on Cygwin like on Linux
Related
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.
When I try to execute cmd commands such as wsl -l, wsl returns this message:
/bin/bash: -c: option requires an argument
However, using wsl as a bash command launcher works.
What do I have to do in order to use wsl windows options such as wsl -l, wsl --install, etc.?
Thanks in advance!
I assume that you've entered wsl command in the Linux terminal and when you did this the first time bash answered you that the command was not found , so you installed 'wsl' package. This is a completely different package. If you want to invoke Windows binaries from bash you should use .exe file extension. Try wsl.exe -l
I am favorite user of WSL.
Before Restoring my Windows 10 OS, I setup WSL in my Windows and I didn't change any configuration. But One Day, the bash command were executed in CMD immediately. So, If I opened CMD and run a command such as 'ls', then result was the same in bash thing.
However now, I restore my windows and above command excuting no longer occurs. I often use bash commands, so I want to execute bash command in CMD. What should I do?
I'm sorry if this is a simple question:
I want to swap from ubuntu to windows for my web dev (personal preference). I'm used to using the terminal in ubuntu and the commands there and I was wondering whether the command prompt in windows is the same? Do the commands do the same?
If not, is there a way to get a terminal for windows the same as ubuntu?
No the Command prompt is not same as the Linux shell you may find some commands resembling to those of the shell in Linux (terminal) however to get a more Linux shell like environment you can install cygwin or GOW (Gnu on Windows). It will give you a bash.
You can find Cygwin here . and
You can find GOW here .
Its not the same, as others have answered, but since the latest version of windows 10 there is a way of running linux bash terminal in Windows.
Have a look in Bash on Windows.
It is actually running Ubuntu inside your Windows.
Windows is based on DOS but Ubuntu is based on Linux. Each of those has its own commands, with some similar commands. I personally prefer Linux commands as they are easier to understand and more simple than DOS commands. You can't use Linux commands in DOS nor the reverse.
I installed amazonCLI, as well as Cygwin, and changed the Path env variable to:
%SystemRoot%\System32\Wbem;C:\Program Files\Prio;C:\Program
Files\Diskeeper Corporation\ExpressCache\;C:\Program
Files\Amazon\AWSCLI\;C:\cygwin64\bin
When I open the command prompt, first of all it is directly pointing to
C:\Users\Stephane
(which I think is weird). And then when I input something like 'ls', the return error is:
'ls' is not recognized as internal or external command, operable program or batch file
Can you please help me know what I am doing wrong?
Thanks
From the error message you got, it's evident, that you are trying to execute Cygwin's commands from the Windows Console. That's also the reason, why it's executed in your Windows' profile directory instead of the Cygwin's one.
You should read the basics about using the Cygwin first, because it seems you don't know what Cygwin exactly is and how to use it. Maybe you don't need the Cygwin at all, it depends on what you need to accomplish. The is for example GnuWin tool set or UnxUtils, which are just a sets of standalone GNU tools compiled for Windows. Cygwin is more like system than standalone utilities. You can for example execute shell scripts under the Cygwin.
So it depends on your needs. But I simply can't imagine using Windows without Cygwin yet.
You can execute Cygwin's shell from the Windows Console, but I advice you to use MinTTY (which is in directory $CYGWIN_DIR/bin). MinTTY is a terminal emulator, which executes your Cygwin shell (bash by default).
To execute for example bash directly from the Windows Console, just execute $CYGWIN_DIR/bash.exe --login -i.