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

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.

Replies are listed 'Best First'.
Re^4: Need to capture return code
by James_Marcinek (Initiate) on Oct 11, 2004 at 19:19 UTC
    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.

        I was thinking of something similar:

        if ($? ne 0) { print ERRLOG "$FILE"; }

        Does $? work with NT in perl?