Results 1 to 14 of 14
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    43

    Unanswered: execute unix command in perl script

    hi
    I am trying to execute the following unix command through perl script
    but it gives this error.

    find: incomplete statement


    @out_dir = qx(find /software/development/Netting/pg29909/Netting -exec grep -i -l '\<ftp\>' {} \;

    I want to store output in a array...

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    you have several possibilities to execute unix commands:
    Code:
    my $returncode = `unix command`; # backticks
    system("unix command");
    exec "unix command";

  3. #3
    Join Date
    Feb 2004
    Location
    UK
    Posts
    43

    Executing unix command inside perl script

    Hi Reeneb

    I have already tried to execute unix command using system and exec ..
    but is does not work.
    If the command return more then one line we can not use system and exec. As in my case I am storing result into array because it may return more then one value..Is there any solution to execute..somewhere I am doing something wrong.

    It alway gives the same error i.e.

    find: incomplete statement

  4. #4
    Join Date
    Feb 2004
    Location
    Philippines
    Posts
    4

    Re: Executing unix command inside perl script

    you can use the backtick...like

    my $returncode = `unix command`; # backticks
    my @array = split/\n/. $returncode;

  5. #5
    Join Date
    Feb 2004
    Location
    UK
    Posts
    43

    Executing unix command inside perl script

    hi cael
    I hv already tried backticks...but the same error I am getting...
    ie Find incomplete

  6. #6
    Join Date
    Feb 2004
    Location
    Philippines
    Posts
    4

    Re: Executing unix command inside perl script

    Originally posted by pangup_74
    hi cael
    I hv already tried backticks...but the same error I am getting...
    ie Find incomplete
    is this the command?...

    my $result = `find /software/development/Netting/pg29909/Netting -exec grep -i -l '\<ftp\>' {} \`;

    have you tried to run it in the unix shell?

  7. #7
    Join Date
    Feb 2004
    Location
    UK
    Posts
    43

    executing unix command in perl script

    No this is the command

    my $result = `find /software/development/Netting/pg29909/Netting -exec grep -i -l '\<ftp\>' {} \;`;

    and it gives following error when I run it inside perl

    find: incomplete statement

  8. #8
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    this is no perl-problem. Check the syntax of find-command.
    board.perl-community.de - The German Perl-Community

  9. #9
    Join Date
    Feb 2004
    Location
    UK
    Posts
    43

    executing unix command inside Perl

    No this is not the command problem because it is working fine on the unix command prompt...There is some problem of quote's..which is I am not able to solve...

  10. #10
    Join Date
    Mar 2004
    Posts
    1

    Re: executing unix command inside Perl

    Try this, it worked for me. Note the two \ at the end.

    my @result = `find /software/development/Netting/pg29909/Netting -exec grep -i -l '\<ftp\>' {} \\;`;

  11. #11
    Join Date
    Feb 2004
    Location
    UK
    Posts
    43
    hi farab
    I hv already done this but any way thanks

  12. #12
    Join Date
    Feb 2008
    Posts
    8

    Unhappy Kshtoperl

    I am finding the same problem!!! Any solutions?

    I tried

    @output = qx (`find /u/msamtest/log/calypso/calypso_link/qa/20080319 -name "FitsMessage.log" -exec ls -t {} \;`);

    But i am getting the following error

    find: incomplete statement


    Any help please

  13. #13
    Join Date
    Feb 2008
    Posts
    8
    solved..same as before worked

  14. #14
    Join Date
    Nov 2008
    Posts
    3
    Hi

    I am able to use the sqlldr in shell command but when i try to use the same in the perl script i am facing problem

    The following is the command which i am using

    sub oracleConnectivity()
    {
    my $db_instance = $PROPERTIES{"ENCORE_DB_INSTANCE_NAME"};
    my $db_user = $PROPERTIES{"ENCORE_DB_SCHEMA_NAME"};
    my $db_pass = $PROPERTIES{"ENCORE_DB_PASSWORD"};
    my $encore_table = $PROPERTIES{"ENCORE_TABLE"};

    my $bad_file = $PROPERTIES{"ENCORE_SECURITIES_BAD"};
    my $cntrl_file = $PROPERTIES{"ENCORE_SECURITIES_CTRL"};
    my $log_file = $PROPERTIES{"ENCORE_SECURITIES_LOG"};
    my $data_file = $PROPERTIES{"ONETIMELOAD_DIR"}."/".$PROPERTIES{"ONETIMELOAD_FILE"};

    &Log ("The data file is $data_file");
    &Log ("The bad file is $bad_file");
    &Log ("The control file is $cntrl_file");
    &Log ("The db instance is $db_instance ");
    &Log ("The db user is $db_user");
    &Log ("The db pass is $db_pass");
    &Log ("The log file is $log_file");

    `sqlldr '$db_user'/'$db_pass'@'$db_instance' \
    data='$data_file' \
    bad='$bad_file' \
    control='$cntrl_file' \
    log='$log_file'`;
    }
    The error which i am getting is

    SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
    ORA-12545: Connect failed because target host or object does not exist


    Iam not getting the same when i use in shell script

    any clues

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •