1

I am not sure how to run aps.bat command within a shell script on Windows 10.

I have tried a couple of different approaches, without success I do not have more details.

Please have a look at the code below:

#!/bin/bash

output = aps.bat build $PWD;

# do some work...

echo "$output";

Basically, I need aps.bat command to be executed and to store the output to the variable.

1
  • Executing a batch script on bash? Why not just port it to a bash script? Commented Oct 28, 2017 at 23:05

2 Answers 2

4
#!/bin/bash

cd /e
output=$(cmd.exe /C  "aps.bat build $PWD")

# do some work...

echo $output
Sign up to request clarification or add additional context in comments.

8 Comments

Unfortunately, I am getting the same result :( 'line 3: aps: command not found'. I have pre-push file with the code written above and I am trying to setup git hook.
try output=$(cmd "/C aps.bat build $PWD")
Still the same :( I tried 'output=$(cmd "/e/aps.bat build $PWD")' since .bat is in the 'E' disk, I am executing script inside gitbash using this command './pre-push'. I am not sure what is wrong whit this approach?
Nothing's wrong, but gitbash might think another way. Try to cd to /e and then start aps.bat ...
It is not finding cmd.exe. You need to specify the full mount path to cmd.exe and most likely the full path to the batch file. msdn.microsoft.com/en-us/commandline/wsl/interop
|
0

Below piece of script should work, given that the bat script should be in the same path as shell script

#!/bin/bash

output = $cmd ./aps.bat build $PWD;

#do some work...

echo "$output";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.