Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Apr 2024
Posts: 385
|
Cygwin to Run Shell Scripts on Windows
How do I use Cygwin to run MacOS/Linux shell scripts like these on Windows?
https://silvae86.github.io/2021/02/1...google-photos/ |
![]() |
![]() |
![]() |
#2 | Link |
Software Developer
![]() Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
|
Just install Cygwin with the installer from the official web-site and then run "cygwin.bat" from Cygwin install directory to open a terminal:
https://www.cygwin.com/ But be aware: Even though Cygwin allows you to run shell scripts on Windows, and it provides most of the "standard" Unix tools (bash, make, grep, etc. pp.), not every Linux or MacOS script/command will "magically" just work 1:1 on Windows! For example, "brew" (Homebrew) is a package manager for MacOS, so it won't work on Windows/Cygwin. If you want to install packages in Cygwin, just use Cygwin's package manager, i.e. Cygwin Setup ![]() https://www.cygwin.com/install.html
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 10th March 2025 at 01:31. |
![]() |
![]() |
![]() |
#3 | Link | |
Registered User
Join Date: Apr 2024
Posts: 385
|
Quote:
Which file format/extension should I put the script in? |
|
![]() |
![]() |
![]() |
#4 | Link | |
Software Developer
![]() Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
|
Quote:
Once you have saved the script, run "cygwin.bat" from Cygwin install directory to open a terminal, then (in the terminal) "cd" to the directory where your script file is located, and then run "./my_script.sh". Note that a Windows path like "C:\path\to\my_script.sh" would translate to "/cygdrive/c/path/to/my_script.sh" in Cygwin. ![]()
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 10th March 2025 at 21:20. |
|
![]() |
![]() |
![]() |
#5 | Link |
Registered User
Join Date: Apr 2024
Posts: 385
|
Quote:
What does that translate to? Is there a tool for this sort of thing? Also, do I add "./" at the beginning of it? |
![]() |
![]() |
![]() |
#6 | Link | |
Software Developer
![]() Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
|
Quote:
![]() Yes, and it's called "cygpath" ![]() But you don't normally need that. It's not that complicated. All your Windows "drives" are mounted at "/cygdrive/x/" by default, with "x" being the corresponding Windows "drive letter". So, your "C:" drive will be mounted at "/cygdrive/c/", your "D:" drive will be mounted at "/cygdrive/d/", and so on... If you want to run an executable or script from the current directory (rather than specifying an absolute path), then yes, you have to put a "./" in front of it! So, with your example, you can either run "cd /cygdrive/c/Users/User/Downloads" followed by "./my_script.sh", or you can just run "/cygdrive/c/Users/User/Downloads/my_script.sh".
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 11th March 2025 at 01:00. |
|
![]() |
![]() |
![]() |
#8 | Link |
Software Developer
![]() Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
|
Uhm, no
![]() As said above, either you use the "cd" command to change the current directory to the directory where your script is located (e.g. "cd /cygdrive/c/Users/User/Downloads"), and then you run "./my_script.sh". ...or you enter the absolute path of the script that you want to run, which would be "/cygdrive/c/Users/User/Downloads/my_script.sh" in your case. (As an aside: You can always run the "pwd" command to check in which directory you currently are!)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 11th March 2025 at 01:12. |
![]() |
![]() |
![]() |
Tags |
cygwin, scripts |
Thread Tools | Search this Thread |
Display Modes | |
|
|