in reply to how to parse output from isql utility
Assuming that this is Sybase (maybe MS-SQL has it as well) you should use the "-s" command-line argument to specify a column separator that is unlikely to occur in the data. You should also specify the "-w" argument with a large integer to make sure that isql doesn't wrap any of the output lines. So something like this could work:
That being said - using DBI and the appropriate DBD driver is a lot better. It's faster, and error handling is much easier.open(TMP, ">/tmp/t$$.sql") || die "can't open temp file: $!"; # Set nocount to avoid the "xxx rows affected" message in isql print TMP "set nocount on\ngo\nselect * from the_table\ngo\n"; close(TMP); # Note: -b flag suppresses column headers. open(ISQL, "isql -Ujoe -Pjoespwd -Smyserver -s'%%^^%%' -w 1024 -b -i / +tmp/t$$.sql") || die "Can't run isql: $!"; while(<ISQL>) { chomp; my @row = split(/%%^^%%/, $_); .... do something with the @row of data.... } close(ISQL);
Michael
|
|---|