Reputation: 13
I have the following simple Windows batch script:
@echo off
echo Parameter 1: "%~1"
echo Parameter 2: "%~2"
When I execute it from the Windows command line (cmd) I get the following desired output:
C:\windows-script.bat "a=1" b
Parameter 1: "a=1"
Parameter 2: "b"
I now would like to execute the same script from a Cygwin bash command line and get the same output. Unfortunately I was not able to achieve what I want. Here are three unsuccessful trials:
$ /cygdrive/c/windows-script.bat "a=1" b
Parameter 1: "a"
Parameter 2: "1"
$ /cygdrive/c/windows-script.bat 'a=1' b
Parameter 1: "a"
Parameter 2: "1"
$ /cygdrive/c/windows-script.bat '"a=1"' b
Parameter 1: "\"a"
Parameter 2: "1\"""
Any ideas how to execute the batch script from Cygwin bash in the desired way?
Upvotes: 1
Views: 242
Reputation: 26537
This is one way of running it :
$ cmd <<< 'C:\windows-script.bat "a=1" b'
The syntax of <<<
is equivalent to typing :
cmd
then typing :
C:\windows-script.bat "a=1" b
For more detail on <<<
, see man bash
Upvotes: 1