Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] slightly OT, SQL question.

Expand Messages
  • Franki
    Hi Richard, Thanks for that, I know that either system, or backtics will return any message of the program ran,, if memory serves, that would be backtics, so I
    Message 1 of 2 , Jan 28, 2003
    • 0 Attachment
      Hi Richard,

      Thanks for that, I know that either system, or backtics will return any
      message of the program ran,, if memory serves, that would be backtics, so I
      guess I am going to use them.. then I can catch its return value on success
      and failure and take appropriate action accordingly...

      I didn't know about the -p space thing, thats a useful thing to know.....
      :-) thanks...


      regards

      Franki

      -----Original Message-----
      From: richardb@... [mailto:richardb@...]
      Sent: Tuesday, 28 January 2003 3:51 PM
      To: perl-beginner@yahoogroups.com
      Subject: Re: [PBML] slightly OT, SQL question.



      Hi Franki,
      You should remove the space between -p and the actual password, mysql will
      treat it as interactive thats why it ask you to type in.
      heres the modified loop:

      foreach my $file (@files)
      {
      system("mysql -u username -ppassword db_name $sql_directory/$file");
      unlink $file;
      }

      or you can try also this way:

      foreach my $file (@files)
      {
      `/usr/local/mysql/bin/mysql -u username -ppassword db_name
      $sql_directory/$file`;
      unlink $file;
      }

      just make sure to get the corect absolute path of your mysql client.

      Hope it helps..



      Best Regards,
      Richard


      "Franki" <frankieh@...> 28/01/2003 02:19 PM
      Please respond to perl-beginner

      To: <perl-beginner@yahoogroups.com>
      cc: (bcc: BORNAY Richard/Engr/STATS/ST Group)
      Subject: [PBML] slightly OT, SQL question.








      Hi guys,

      I am now writing the "system" version of my script that grabs sql files and
      imports them...

      I have the SQL file names all in an array called @files

      and then this:

      foreach my $file (@files)
      {
      system("mysql -u username -p password db_name $sql_directory/$file");
      unlink $file;
      }

      which would hopefully grab the sql files one at a time, hand them to mysql
      client and then delete the file...

      I have a problem with this, the -p password bit doesn't work like that on
      my
      systems, on the console you put the -p in there, and then it will ask you
      for the password manually, entered on STDIN...

      Is there a way to pass it as part of the actual command or do I need to
      pass
      it via the perl script.???

      Also, is there some way of testing what the system command returned ?? so
      if
      its not successful for whatever reason, I can send an email report on the
      problem and not unlink the file...


      Any tips would be great..

      It would appear that using DBI would have been faster to write, but not as
      fast to run. (particularly since all it really does is call the mysql
      client
      itself anyway.)


      regards

      Franki


      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





      [This e-mail is confidential and may also be privileged. If you are not the
      intended recipient, please delete it and notify us immediately; you should
      not copy or use it for any purpose, nor disclose its contents to any other
      person. Thank you.]



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    Your message has been successfully submitted and would be delivered to recipients shortly.