Can i use mySQL from inside awk code
Basically i want the data AWKED in this post
into Mysql database
Can i use mySQL from inside awk code
Basically i want the data AWKED in this post
into Mysql database
Based on the linked question it appears that you would like to log statistics obtained from rsync --stats
, i.e. something like this:
Number of files: 4
Number of files transferred: 0
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 66
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 80
Total bytes received: 13
sent 80 bytes received 13 bytes 186.00 bytes/sec
total size is 0 speedup is 0.00
You could parse the interesting bits from that output with AWK and then output an appropriate SQL statement. Something like this:
#!/usr/bin/awk -f
/^Number of files: / {
num_files = $4;
}
/^Number of files transferred: / {
num_tranferred = $5;
}
/* etc... */
END {
printf("INSERT INTO some_table (num_files, num_transferred) \
VALUES (%d, %d);\n", num_files, num_transferred);
}
You're probably trying to use a hammer with a screw here :) You definitely should use a language like Perl, Python or Ruby for this. It will be much faster, and more solid. Even PHP would be better, actually :)