call perl script in cygwin - windows

I would like to start perl.pl within a cygwin terminal such that perl.pl starts in a new cygwin terminal.
What is the best way to do this?
So far I've tried to use system(perl.pl) and exec(perl.pl), but that runs the perl script within the windows command line, not cygwin.

As you can see by viewing the properties of the shortcut, the command that opens the terminal is
mintty.exe -i /Cygwin-Terminal.ico -s 105,60 -
So you'd run
system('mintty perl.pl');

Use command xterm:
xterm -hold -e perl.pl

Related

Call a MobaXterm command from a bash script

From my /home/mobaxterm command prompt, I can use the newtab "command" to launch a new tab and execute a command just fine. When I use it inside a bash script, I get "newtab: command not found".
Is there special coding required to use the MobaXterm commandline parameters as found here: https://blog.mobatek.net/post/mobaxterm-command-lines/ inside a bash script?
Thanks.
Use this
/bin/MobaSendMsg.exe MobaXterm -newtab "YOUR_COMMAND"

Windows/Cygwin equivalents of linux screen and $()?

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

Git-Bash shortcut to run command

My current shortcut has the following target: C:\Development\Git\git-bash.exe
How do i get it to execute something more complex such as:
C:\Development\Git\git-bash.exe **ls**
or
C:\Development\Git\git-bash.exe **java -jar myfile.war**
You can modify the shortcut with:
bash.exe --init-file <(echo "ls; pwd")
If you want git-bash, and in order to avoid git-bash to just open and close a Windows immediately after executing those commands, you would execute (or modify the shortcut):
C:\Development\Git\git-bash.exe -c "ls; $SHELL"
That way, the shell remains in place after executing the first commands you want.
As noted in Baker's comment
In Windows 10/11 the shortcut target is particular about quotes.
This format seems to work:
"C:\Program Files\Git\git-bash.exe" -c "emulator -avd Pixel3a -writable-system; $SHELL"

Using Windows subsystem for Linux in Sublime

For example, how to run "make" command in Bash instead of CMD ? I tried to write my own buildsystem "bash -c make", but sublime can't recognize commnad bash (which is added also to PATH). Thanks :)

how to write a batch (windows) to start Cygwin (mintty.exe) and then execute a python script?

Pretty much as titled. If I were to manually do this, I would first open a Cygwin Terminal (which should be /cygwin/bin/mintty.exe), and then in that terminal, cd to the directory that has the python script, and then execute the python script by doing "python myPython.py". I'm wondering if I can write a batch script or a bash script to do this: start a Cygwin Terminal, cd to a directory, execute a python script in the directory.
Thanks.
Edited:
So I have a python script that generates csv files for activities through mongodb.This script won't function if I run it through windows cmd. I have to run it in cygwin terminal (mintty.exe). So any alternatives to execute the python script won't work. I have to somehow start a Cygwin Terminal and execute the python script through there. Any ideas please? Thanks.
Depending of your needs it could be better to start mintty (creating a new window) instead of starting bash inside the cmd.exe window.
When you want to use ansi escape sequences then it works better with a real mintty window, as the cmd window ignores the escape sequences for window resizing and positioning.
start "" C:\cygwin\bin\mintty --exec ./myProgramToExecute.sh
You may start a bash from the Windows terminal and start your script from there (without starting mintty.exe). Just execute
bash -c "cd /your/directory && python myPython.py"
from the Windows cmd prompt or a batch file.

Resources