Forum OpenACS Development: Re: NaviServer 4.99: Issues with "rename"?

Collapse
Posted by Maurizio Martignano on
Dear Frank and Gustaf,
let me add some few points to this discussion.
When calling an external program/utility we basically need two things:
1. know where the program is (so that we can call it)
2. pass to it the proper parameters (in case they are needed).
Up to now in the discussion you have covered only point 1.
But suppose our program/utility requires as parameter a file name.
In this case file naming conventions are also important "inside" the command line parameters.
Things become even trickier when we used mixed models of file naming conventions. I'll try to explain: in Linux all executable binaries follow the same files naming conventions. In pure Windows, when all the executable binaries are all native Windows binaries, they all follow the same files naming conventions.
On the contrary when some of the binaries are Windows native and others are Cygwin (or MinGW) binaries they are not guaranteed to follow the same files naming conventions.

Hope it helps,
Maurizio

Collapse
Posted by Maurizio Martignano on
I'm adding an example to explain my point.
Let's take the following simple C Program:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define LEN 2048

char command[LEN+1];

int main(int argc, char *argv[]) {
    int i;    
    for (i = 1; i < argc; i++) {
        strcat(command, argv[i]);
        strcat(command, " ");
    }
    printf("Executing command = %s...\n", command);
    system(command);
    printf("Done!\n");
    return 0;
}

Let's compile it both as Native Windows (exec_win) and as Cygwin-64 (exec_cyg) and let's run it from within Cygwin-64...

Maurizio@MMNASUS /cygdrive/c/smart/prog/provec
$ exec_win which ls
/usr/bin/ls
Executing command = which ls ...
Done!

Maurizio@MMNASUS /cygdrive/c/smart/prog/provec
$ exec_cyg which ls
Executing command = which ls ...
/usr/bin/ls
Done!

Maurizio@MMNASUS /cygdrive/c/smart/prog/provec
$ exec_win ls c:\\tmp
Executing command = ls c:\tmp ...
Done!

Maurizio@MMNASUS /cygdrive/c/smart/prog/provec
$ exec_cyg ls c:\\tmp
Executing command = ls c:\tmp ...
ls: cannot access 'c:tmp': No such file or directory
Done!