find in system() [Archive] - C Board

PDA

View Full Version : find in system()


Unregistered
03-23-2002, 01:08 PM
I have a system() call with a find statement in it but i don't want the results printed.

I know that -print is automatic unless you specify -ok.

when i do i get errors --->>
find: 0652-018 An expression term lacks a required parameter.


system("find . -type d -name \"savedir\" -ok ")

xlordt
03-23-2002, 02:55 PM
make sure that you are adding the header file #include <stdlib.h> <-- this file is needed to run system commandz

Deckard
03-25-2002, 08:49 AM
Hi,

The problem lies with your use of the -ok switch (-ok requires an argument). The -ok switch will execute another application, just like -exec, but will prompt the user before each execution.

If you do not want the results of find to be sent to stdout, redirect them:

system( "find . -type d -name \"savedir\" > /dev/null" );

Also, the quotation marks around savedir are not necessary, so the following is also valid:

system( "find . -type d -name savedir > /dev/null" );


Cheers,