Jaki1980 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks , I have the following code
my $sqlsource = mySql.sql open( SQLPLUS, "|sqlplus /nolog") or die "Can't rus sqlplus\n" ; print SQLPLUS <<SQL; connect USERNAME/PASS\@INST \@$sqlsource SQL
It is working fine as far as conecting to the database , however it is not finiding my $sqlsource eventhough I am in the righ directory , I get error like this
SQL> Connected. SQL> unable to open file "mySql.sql"
Is it the way I am calling the script , I am not sure if it is adding a space or somthing . Can someone advice please? thanks

Replies are listed 'Best First'.
Re: sql prompt not finding file
by Plankton (Vicar) on Jan 15, 2004 at 23:06 UTC
    What you have should work provided:
  • my $sqlsource = mySql.sql is a typo (your missing the ; and "'s)
  • the file mySql.sql actually exist.
    Maybe you should check the file before using it like so ...
    #!/usr/local/bin/perl -w my $sqlsource = "mySql.sql"; if ( -r $sqlsource ) { open( SQLPLUS, "|sqlplus /nolog") or die "Can't rus sqlplus\n" ; print SQLPLUS <<SQL; connect USER/PASS\@SID \@$sqlsource SQL } else { print "$sqlsource is not readable\n"; }

    Plankton: 1% Evil, 99% Hot Gas.
      thanks all finally got it to work . As you mention, it was a mode issue. thanks
Re: sql prompt not finding file
by CountZero (Bishop) on Jan 15, 2004 at 23:04 UTC
    At first sight there is nothing wrong with calling the script. It seems to parse the data right, but can't open the file "mySql.sql". It could be a matter of file permissions. Perhaps SQLPLUS is not allowed to open mySql.sql.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: sql prompt not finding file
by pg (Canon) on Jan 15, 2004 at 22:58 UTC

    As I said in this reply earlier, the problem is not in the part you showed us. Even with your original syntax, it worked fine for me.

    The current issue you just showed is more to do with sql*plus and your environment, not Perl.