How can I run a script inside cygwin after it launches?
I want to automatically add some mounts and run other scripts inside cygwin whenever it starts. I see that in linux it is as simply as adding a shell file inside etc/init.d However, i tried adding this dir and chmod +x add a shell, chmod that shell file, but does not work.
Also if there is a way to run scripts when closing like umount, rmdir and others.
On Windows, the simplest way of running a program at startup is to place an executable file in the Startup folder. All the programs that are in this folder will be executed automatically when the computer opens. You can open this folder more easily by pressing WINDOWS KEY + R and then copying this text shell:startup .
So you have to use simply /bin/ as path for bash. Do a simple check: into a CygWin terminal type the command ls /bin/bash.exe : it list the executable for bash. open a windows CMD and type the command dir C:\cygwin\bin\bash.exe : it list the executable for bash.
What you are looking for is
~/.bash_profile
AKA
C:\cygwin\home\CPJ\.bash_profile
With a stock install this file is read on Cygwin startup. If you would like to add more files you can edit the .bash_profile
file, for example
source foo.sh
source bar.sh
source baz.sh
Bash man page
I am sorry to add to this very old question, but I think the accepted answer above has a glitch.
Try to add a command to your .bash_profile as follows which I use for example to open a local SSH port:
ssh -D1080 root@localhost -g localhost
When you login interactively, another SSH session starts, which starts another, and another, and you're in an endless loop.
Thought this might help someone..
.bash_login is what you actually need :P
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With