in reply to Re: Need to capture return code
in thread Need to capture return code

This is my first post
Listfile is the list of files that are to be imported (not the actual data). I'm calling each file then importing the specific file. I'm not MySQL expert either so if there's a way to tell it to import various numbers of files I'd like to know .

Replies are listed 'Best First'.
Re^3: Need to capture return code
by dragonchild (Archbishop) on Oct 11, 2004 at 19:03 UTC
    Well, your code isn't doing that. Your code is saying that you have a list of MySQL commands in listfile2 and you're running through those commands one by one.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      You are correct. Since I had to parse log files I reformatted them with another perl script which did not capture some of the trickier entries. My other script added the header and footer lines:

      use database_name;
      insert into table values

      The important thing to know is that it works unless there's a syntax problem with (mentioned above). I've imported over 540million out of the 600 million records. Each file is currently broken into 2500 record rows. I want to capture the error code with the:

      system("mysql < $LISTFILE");

      I can then re-run the import and isolate the problem files
        I use $? to detect errors, but I also use shell scripts to interface with MySQL in a batch mode. Perl is just ... too heavy for this.

        In Perl, you might have to do something like if ($? >> 8) to get it to work right. (I forget the exact syntax and where in the bytes the actual error is stored.)

        Being right, does not endow the right to be rude; politeness costs nothing.
        Being unknowing, is not the same as being stupid.
        Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
        Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.