LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   find: missing argument to `-exec' (http://www.linuxquestions.org/questions/linux-newbie-8/find-missing-argument-to-%60-exec-4175437498/)

IAnilkumar 11-16-2012 06:59 PM

find: missing argument to `-exec'
 
I have written a perl script

my @pin_conf_files = `find . -name "create*.opc" -exec grep -l PIN_FLD_PASSWD_CLEAR {} \;`;

when i compile it throws an error:

find: missing argument to `-exec'

It works on the command prompt.

> find . -name "create*.opc" -exec grep -l PIN_FLD_PASSWD_CLEAR {} \;
./product_priority_test/create_cust_prio.039.opc
./product_priority_test/create_cust_prio.037.opc
./product_priority_test/create_cust_prio.035.opc
./product_priority_test/create_cust_prio.038.opc
./product_priority_test/create_cust_prio.040.opc
./product_priority_test/create_cust_prio.036.opc
./discountable_1_test/create_cust.053to058.opc
./system_product_test/create_cust.088.opc
./date_range_test/create_cust_datetimetest.opc
./date_range_test/create_cust_datetimefail.opc
./sponsorship_test/create_cust.001.opc
./sponsorship_test/create_cust.003.opc
./sponsorship_test/create_cust.002.opc
./multiple_product_test/create_cust_mprod.044.opc
./multiple_product_test/create_cust_mprod.043.opc
./timeofday_1_test/create_cust.opc
./currency_test/create_cust.067.opc
./currency_test/create_cust.068.opc
./discountable_2_test/create_cust.079.opc
./fold_test/create_cust.042.opc
./proratable_test/create_cust.opc
./timeofday_2_test/create_cust.086.opc
./credit_limits_test/create_cust.066.opc
./timezone_test/create_cust.opc
./quantity_1_test/create_cust_quantity.opc
./status_test/create_cust.opc
./usage_test/create_cust.069.opc
./basic_test/create_cust_basic.opc
./basic_test/create_cust_power.opc
./peak_offpeak_test/create_cust_peak_offpeak.opc
./quantity_2_test/create_cust_quantity2.opc

shivaa 11-17-2012 01:04 PM

It seems some pb with script's execution path. Once try to use full path of "exec" or instead of this, try xargs cmd as:
Code:

find . -name "create*.opc" | xargs grep -l PIN_FLD_PASSWD_CLEAR

chrism01 11-19-2012 01:25 AM

Don't do it that way, do the whole thing in Perl.
http://perldoc.perl.org/
http://www.perlmonks.org/?node=Tutorials

Code:

opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
while (defined($file = readdir(DIR)))
{
    # do something with "$dirname/$file"
}
closedir(DIR)or die "can't closedir $dirname: $!";



All times are GMT -5. The time now is 07:09 PM.