Tutorial :issue commands to window/process started from batch file



Question:

I want to pass commands to a process started in a batch file, specifically Cygwin. For instance, if I start Cygwin with something like the following:

start "window1" cmd.exe /c cygwin  

How might I execute 'ls' in "window1", in the same batch file from which I started Cygwin?


Solution:1

I have to ask why you want to run the commands from a batch file? Do you want to take different actions based on the results/output of the commands?

In either case, what you are asking is bordering on impossible. Why don't you simply write your logic in a bash script and run

start "window1" cmd.exe /c c:\cygwin\bin\bash.exe -c [script]

where [script] is the path of your bash script.

Documentation on bash scripting is available at http://tldp.org/LDP/abs/html/


Solution:2

If you don't have cmd arg to cygwin to execute command in startup (like cmd.exe /K or /C) you can automate such thing with some script like AutoHotKey.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »