2010/2/17 Zitt Zitterkopf <zittw...@hotmail.com>:
> Exec( '/bin/mount', '/dev/'+ aline +' /media/' + aline + ' &> /dev/null');

Try:

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

for redirecting STDOUT or

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

for redirecting STDOUT and STDERR.

> I tried the following kludge instead:
> var
> OurPipe    : Text;
>
>          popen( OurPipe, '/bin/mount /dev/'+ aline +' /media/' + aline,
> 'R');
>          Try
>              if (fpgeterrno=0) then Flush (OurPipe)
>              ELSE MessageBox ('mount pipe error ' + IntToStr(fpgeterrno),
> nil,
>                   mfError or mfOKButton);
>          Finally
>              PClose( OurPipe );
>          END;

This works for me:

var f: textfile;
    s: string;
begin
  if popen(f, '/bin/mount /dev/'+ aline +' /media/' + aline + ' 2>&1',
'r') = 0 then
  begin
    readln(f,s);

    // test output 's'

    pclose(f);
  end
  else
    error := fpgeterrno;   // failed
end;

This puts stdout and stderr into one pipe however. There must be some
way to read from stdout and stderr separately, maybe using TProcess,
but I've never needed it so I don't know how.

--
cobines
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to