Notes Linux
Sqlite mit Perl
#!/usr/bin/perl -w
use strict;
use DBI;
use Data::Dumper;
printf("%x",100);
exit 1;
my $dbh = DBI->connect("dbi:SQLite:dbname=dbfile","","");
$dbh->do("CREATE TABLE urlz(time INTEGER,id INTEGER,url STRING PRIMARY KEY);");
$dbh->do("insert into urlz (time,id,url) values (10,3,'http://example.com');");
$dbh->do("insert into urlz (time,id,url) values (13,2,'http://example.com/test.blah');");
my $maxid=$dbh->selectall_arrayref("SELECT id FROM urlz ORDER BY id LIMIT 1;");
print "#####" . Dumper($maxid);
my $test=$dbh->selectall_arrayref("select id from urlz where url = 'http://example.com';");
print Dumper($test);
#$quoted_string = $dbh->quote($string);
Mounten von Partitionen in einem Disk-Image-File
Ermitteln der Zylinder - dazu wird leider die ursprüngliche Platte benötigt:
root@host > fdisk -l
Disk /dev/sda: 4871 MB, 4871301120 bytes
255 heads, 63 sectors/track, 592 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 463 3719016 7 HPFS/NTFS
/dev/sda2 464 592 1036192+ 5 Extended
/dev/sda5 464 479 128488+ 82 Linux swap
/dev/sda6 480 592 907641 83 Linux
Die Zahl 592 ist die Anzahl der der Zylinder. Jetzt wird die Startposition der gewünschten Partition ermitteln:
root@host > fdisk -l -u -C 592 image.img
Disk image.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 592 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
image.img1 *63 7438094 3719016 7 HPFS/NTFS
image.img2 7438095 9510479 1036192+ 5 Extended
image.img5 7438158 7695134 128488+ 82 Linux swap
image.img6 7695198 9510479 907641 83 Linux
Im Falle von Partition 1 wäre der Startblock 63. Jetzt wird gemountet:
root@host > mount image.img /mnt -oloop,offset=$((63*512))
Fertig.
[Zurück zum Start]