[fpc-pascal] How to exec() arguments with spaces?

Jan Je/lowicki Jasj at OZI.AR.WROC.PL
Fri Nov 26 20:13:03 CET 2004


I am using fpc 1.0.10 in both Unix and W32. Need to process 
an external file with external binary program:

    exec(myprog, myfile);

I cannot process this way any file that name contains whitespaces.
Replacing 'my file' with '"my file"', 'my\ file', '"my\ file"'
has no effect; apart from that exec(myprog, '"myfile"') does not work 
even if filename has no spaces.
The problem seems to depend on the way of passing arguments to the 
program, not on the program itself: many programs like /bin/cat, 
/bin/gzip, and others behave similarily.

    execv(myprog + ' '+myfile);
    exec(myprog+ ' '+myfile, '');
result the same.
The problem is only in Unix. What am I doing wrong?


                                       Jan Jelowicki
                                       jasj at ozi.ar.wroc.pl
Wroclaw University of Agriculture    Akademia Rolnicza we Wroclawiu
Department of Mathematics            Katedra Matematyki

More information about the fpc-pascal mailing list