2

In my program I have to use the diff command from SUA to find out the difference of 2 files.

I use the a command as follows,

diff xx yy

here

xx - /a/s/xx.txt

yy - /a/s/yy/txt

The path of xx.txt and yy.txt is in Windows format. But in SUA 'diff' command accepts the path in UNIX format as /dev/fs/C/a/s/xx.txt and /dev/fs/C/a/s/yy.txt.

We have a command winpath2unix that will convert the path into Unix format. So I want to use the diff command as follows in my program,

diff 'winpath2unix xx' 'winpath2unix yy'

Here I want to run winpath2unix command first and need to pass the output of these commands to diff command.

In C shell it is working fine. But in the command prompt its not working.

Is there any option to run this command?

Or how can i use csh in CreateProcess?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
San
  • 23
  • 5

2 Answers2

0

I think I found your question on some other forum. :)

Use -c to send a command as argument to tcsh, "" is used to quote double quotes, if the path winpath prints a path including space.

LPTSTR cmd[] = _tcsdup(TEXT("C:\\Windows\\posix.exe /u /c /bin/tcsh -c \"/bin/diff \"\"`winpath2unix /x/xx.txt`\"\" \"\"`winpath2unix /x/yy.txt`\"\"\""));

int RetVal = CreateProcess(NULL,
                           cmd,
                           NULL,
                           NULL,
                           TRUE,
                           NORMAL_PRIORITY_CLASS,
                           NULL,
                           NULL,
                           &sInfo,
                           &pInfo);
DWORD error = GetLastError();

More info here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

emil
  • 1,642
  • 13
  • 12
0

If by the command prompt, you mean cmd.exe, there is a trick that can help you which uses the FOR command to set a variable in a batch file. So you would create a batch file that looked something like this

@ECHO OFF
FOR /F "tokens=1 delims=" %%A in ('winpath2unix %1') do SET xxWinPath=%%A
FOR /F "tokens=1 delims=" %%A in ('winpath2unix %2') do SET yyWinPath=%%A
diff xxWinPath yyWinPath

If we called this batch file doDiff.bat, you would call it with the syntax doDiff.bat xx yy.

Another description of this technique is here. Raymond Chen also demonstrates a similar technique here. The official documentation lives on MSDN under the header Iterating and file parsing.

dsolimano
  • 8,870
  • 3
  • 48
  • 63