BLaZuRE
BLaZuRE

Reputation: 2406

Execute Windows command from Cygwin bash script

I am using Windows with Cygwin installed and have a bash script. Since Cygwin's implementation of the Unix cp command/program is flawed for Windows on default installation (fails to preserve Windows permissions unless Cygwin is installed with certain flags), I would like to issue Windows' native copy command from the bash script instead.

Is there a way for me to issue this (and possibly any generic Windows Command Prompt command) and be able to handle errors (say copy fails due to UAC, file not found, network drive unreachable, etc.) from within the bash script?

Upvotes: 2

Views: 1109

Answers (2)

SachaDee
SachaDee

Reputation: 9545

In Windows BAT :

copy "YourFile.xyz" "ToDestinationPath(.xyz)" && (
              Echo Copy ==^> Success
                  ) || (
              Echo Copy ==^> Failed) 

Upvotes: 1

Paul
Paul

Reputation: 2710

I don't have cygwin right now but one of the following should works

./test.bat params
cmd /c test.bat params
cmd /c copy /?

Remember the quotes/double quotes can be interpreted differently between cmd and bash.

Upvotes: 1

Related Questions