find in system()

This is a discussion on find in system() within the Linux Programming forums, part of the Platform Specific Boards category; I have a system() call with a find statement in it but i don't want the results printed. I know ...

  1. #1
    Unregistered
    Guest

    find in system()

    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.

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

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    make sure that you are adding the header file #include <stdlib.h> <-- this file is needed to run system commandz

  3. #3
    B26354 Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    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:
    Code:
    system( "find . -type d -name \"savedir\" > /dev/null" );
    Also, the quotation marks around savedir are not necessary, so the following is also valid:
    Code:
    system( "find . -type d -name savedir > /dev/null" );
    Cheers,
    Jason Deckard

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a C Programing Quiz project
    By dilemma in forum C Programming
    Replies: 12
    Last Post: 05-15-2009, 04:35 PM
  2. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  3. Replies: 17
    Last Post: 04-02-2008, 01:09 PM
  4. Replies: 5
    Last Post: 04-16-2004, 02:29 AM
  5. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21