Issue while executing the multi-layer commands on windows

48 views Asked by At

The below is executing on windows:

C:\cygwin\bin\bash.exe  -c "echo abc; echo 1 ; c:/cygwin/bin/bash.exe -c "c:/cygwin/bin/tcsh.exe echo def; pwd "  "

Running the above command, and getting the output as:

abc
1
[PPP@machine1 ...Users/PPP]$ 

Desired Output:

 abc
 1
 def
 C:\Users\PPP 

In all, I want the commands under tcsh to also work (In above command, it is "echo def; pwd"). How can I have the progress on it?

1

There are 1 answers

0
matzeri On

It is possible that you really want to nest multiples calls as
bash -> bash -> tcsh

A possible way to do it

C:\cygwin64\bin\bash.exe  -c "echo abc; echo 1 ; c:/cygwin64/bin/bash.exe -c 'c:/cygwin64/bin/tcsh.exe -c \"echo def \" ; pwd '  "

and the output on my W10 CMD is

abc
1
def
/cygdrive/c/Users/marco

but it is horrible and a lot is superfluous. Still horrible but simplified, using the first call as login-shell

C:\cygwin64\bin\bash.exe  -l -c "echo abc; echo 1 ; bash -c 'tcsh.exe -c \"echo def \" ; pwd '  "

and the output is

abc
1
def
/home/marco

In general I miss the need of all the nested calls, and writing a simple shell scripts with all command should be enough. Also using a batch file like

--- prova.bat -----

@echo off

C:
chdir C:\cygwin64\bin

set A=%1
bash --login  -c "/usr/bin/echo $(cygpath $A)"
pause 

--- end --------