Sending commands in batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bi89405
Posts: 3
Joined: 02 Jul 2012 10:28

Sending commands in batch file

#1 Post by bi89405 » 02 Jul 2012 10:33

Hello,

I am new to creating batch files.

I am trying to launch an application called cygwin and then when the shell opens, I'd like to submit 3 commands, each having a carriage return, then exit the application.

Can anyone please advise?

Best regards,
Zack H.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Sending commands in batch file

#2 Post by Squashman » 02 Jul 2012 11:29

If I am not mistaken cygwin has its own shell. You should probably make your script execute within that shell instead of writing a batch file.

bi89405
Posts: 3
Joined: 02 Jul 2012 10:28

Re: Sending commands in batch file

#3 Post by bi89405 » 02 Jul 2012 11:43

Hi Squashman,

When I launch my cygwin, I get straight through the Cygwin Command Shell prompt. I am not familiar with how to create a batch from the shell.

Is there a way to do it via Batch?

Thanks!
Zack H.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Sending commands in batch file

#4 Post by Squashman » 02 Jul 2012 11:56

Cygwin basically comes with a BASH shell. So you can basically write bash script just like you would on other Unix and Linux platforms.

So to execute a Bash script from a Batch file you would do something like this.

Code: Select all

c:\cygwin\bin\bash "c:\MyScript.sh"

bi89405
Posts: 3
Joined: 02 Jul 2012 10:28

Re: Sending commands in batch file

#5 Post by bi89405 » 02 Jul 2012 12:16

I apologize but I don't use Unix. Someone was kind enough to create a process for me that works using cygwin. I am simply trying to automate the scripts given to me.

I tried implementing your suggestion using bash but I have had no success. I run the execution commands but screen quickly disappears.

Any help on how I can pass the commands to the cygwin shell?

TIA,
Zack H.

Post Reply