[fpc-pascal] Exec(), Linux, and /dev/null redirection

Zitt Zitterkopf zittware at hotmail.com
Wed Feb 17 01:34:08 CET 2010

I'm cross developing a program in free pascal running FreeVision. When running under Linux / Busybox; I'm attempting to mount a device to scan it for a set of files. Since I'm running a TUI (Text User Interface); I cannot have the BusyBox mount command printing failure information to the screen where it corrupts the TUI. The pascal code:


Exec( '/bin/mount', '/dev/'+ aline +' /media/' + aline + ' &> /dev/null');


When running:


Exec( '/bin/mount', '/dev/'+ aline +' /media/' + aline );


I see "device busy" STDERR messages appear on the screen. However, when I try to redirect using the ' &> /dev/null' it appears as tho the BusyBox executable is being passed ' &> /dev/null' as a parameter and isn't taking it as the appropriate redirection command.


I tried the following kludge instead:


OurPipe    : Text;


         popen( OurPipe, '/bin/mount /dev/'+ aline +' /media/' + aline, 'R');
             if (fpgeterrno=0) then Flush (OurPipe)
             ELSE MessageBox ('mount pipe error ' + IntToStr(fpgeterrno), nil,
                  mfError or mfOKButton);
             PClose( OurPipe );


however, I'm getting an Accessviolation. unsure if I'm even going down the right path.


Any other suggestions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100216/dbbe9382/attachment.html>

More information about the fpc-pascal mailing list