Run / call windows script package from sh or bash script

I have a sh / bash script that should call a batch file with parameters (parameters are file names and are specified in DOS / Windows format).

Basically me: script.sh

#!/bin/sh declare var1=$1 declare var2=$2 dosomething var1 var2 ... <invoke batch script> var1 var2 ... dosomethingelse 

I am using GNU bash, version 3.1.0(3)-release (i686-pc-msys) as a shell, on msysgit

The problem is that when I run from a script: $COMSPEC /c batchfile param1 param2 either I get a "blank prompt" that looks like bash, but the command result does not appear on the console, or cmd.exe start but does not execute the script .

I tried referencing params on bash like this:

 $COMSPEC /c \"batchfile param1 param2\" $COMSPEC /c \"\"batchfile param1 param2\"\" $COMSPEC /c \"\"batchfile \"param1\" \"param2\"\"\" 

But I did not get any result.

+7
msysgit bash cmd batch-file
source share
1 answer

It seems I needed to escape the space from params cmd:

 $COMSPEC \/c batch-file\ \"$var1\"\ \"$var2\" 

or

 $COMSPEC /c batch-file\ \"$var1\"\ \"$var2\" 

I'm not sure if / from / c needs to be escaped, but it works fine in both directions.

+10
source share

All Articles