File completed cmd

From MLDonkey
Jump to: navigation, search

The file_completed_cmd script/program is called each time a download is committed. (Note, this does not work on MinGW).

Until MLDonkey 2.7.0 this script was called when a download was completed. This was changed because the filename of the committed file in the incoming directory could not be computed 100% correctly due to naming collisions with files already present in incoming directory. The final name that the completed file will get can only be computed when commit really takes place.

Contents

Arguments and environment

The received arguments are:

cmd <md4-hash> <size> <file-name>

Since MLDonkey 2.7.1 the arguments are set as environmental variables as well as the old arguments for backward compatibility reasons. Here are the environmental variables thar MLDonkey will set for the command:

FILE_GROUP_* are present since 2.8.5:

file_completed_cmd must be activated by setting file_completed_cmd variable. Like from telnet:

set file_completed_cmd "/home/mldonkey/file_completed_cmd"

Old cores

Old cores delay the auto commit operation 30 seconds. Therefore, you have to insert (or activate) in the scripts the auto-commit line from below before you start operations on the actual file, even if you have auto_commit activated in your core. Of course, if you have the commit in your script, you can disable the option in the core.

Since MLDonkey 2.7.1 file_completed_cmd is called after commit took place, so you don't need the auto-commit lines in your script.

Common problems

If command is a shell script, specifying the script interpreter (i.e. #!/bin/bash) is essential or nothing will happen, even if the script has the executable bit. This is a common source of problems with this feature. All scripts need the interpreter specified for the shell, so it's hardly surprising. One could choose to invoke a script with /bin/bash script too.

Scripts

Minimal auto-commit

#!/bin/bash
echo -e "commit\nq" | nc localhost 4000

If this does not work, try:

#!/bin/bash
{ echo commit; sleep 2; } | telnet localhost 4000

Or with if you have to supply a password:

#!/bin/bash
echo -e "auth this_is_my_username this_is_my_password\ncommit\nq" | nc localhost 4000

From here on this is again valid for all versions of MLDonkey

Sending the auth command first is a general need, omitted for brevity in the following examples.

Winpopup notification

Another script for Winpopup notification (original version found in mldonkey-users mailing list):

#!/bin/bash
# file_completed_cmd interface
HASH="$1"
SIZE="$2"
FILENAME="$3"

INCOMING="incoming"

STATION_LMNAME="MYBOX"
STATION_IP=192.168.1.1

{
  echo "New file: $FILENAME"
  echo "Hash: $HASH"
  echo "Size: $SIZE"
  echo "==========================="
  ls -F "$INCOMING"; } | smbclient -M "$STATION_LMNAME" -I $STATION_IP

Indexing your file on bitzi.com

You will need the bitcollider program

#!/bin/bash
# file_completed_cmd interface
HASH="$1"
SIZE="$2"
FILENAME="$3"
INCOMING="incoming"
DISPLAY=${DISPLAY:-:0.0}

nice bitcollider "$INCOMING/$FILENAME" &

Scan file for virus and delete if infected

Scan file for viruses and delete if infected. Alternatively you can activate quarantine code to move infected or untestable files into quarantine directory. (See next script for a solution using Bitdefender, which is more reliable)

#!/bin/bash
# you need netcat and clamav (http://www.clamav.net) package

# file_completed_cmd interface
HASH="$1"
SIZE="$2"
FILENAME="$3"

# some handy variables
ROOTDIR="/home/nouser/mldonkey"
INCOMING="incoming"
# dir for quarantining infected files, on same level as incoming. See bottom of this script.
QUARANTINE="quarantine"

# forcing commit in core, you might need to change "netcat" to "nc"
# depending on your distry, eg. Debian has nc and SuSE has netcat.
echo -e "commit\nq" | netcat localhost 4000

# if you experience problems uncomment follow line to compensate
# for a commit action that doesnt move but copy
#sleep 5

# invoking clam antivirus scan on file and delete it if virus was found
# since clamscan can't disinfect. Log results into file scan.log
# This way, you get entries like "filename: status" in the log, if you
# use the --log option you cant see which files were scanned.
# Hint: Better make the following one line.
clamscan --remove -r --tgz --unzip --unrar --jar --tar --lha --no-summary \
   --stdout "$ROOTDIR/$INCOMING/$FILENAME" >> $ROOTDIR/scan.log

# same as above but quarantinging instead of deleting. This moves all files that are infected
# or caused clamscan to throw an error to quarantine directory.
# Hint: Better make the if line one line only.
# to use this feature uncomment lines below and comment the above
#if  clamscan -r --tgz --unzip --unrar --jar --tar --lha --no-summary \
#   --stdout "$ROOTDIR/$INCOMING/$FILENAME" >> $ROOTDIR/scan.log ; then
#       echo "$FILENAME left in $ROOTDIR/$INCOMING" >> $ROOTDIR/scan.log;
#  else
#       mv "$ROOTDIR/$INCOMING/$FILENAME" "$ROOTDIR/$QUARANTINE/"
#       echo "$FILENAME moved to $ROOTDIR/$QUARANTINE" >> $ROOTDIR/scan.log;
#fi

Virus scanning and quarantining using Bitdefender

Virus scanning and quarantining using Bitdefender. Bitdefender can also disinfect files, which you should attempt manually with the files in quaratinging directory.

#!/bin/bash
# you need netcat and Bitdefender (www.bitdefender.com) package

# when we are executed
EXECDATE=`date`

# file_completed_cmd interface
HASH="$1"
SIZE="$2"
FILENAME="$3"

# some handy variables
ROOTDIR="/home/nouser/mldonkey"
INCOMING="incoming"
# fasttrack and bittorent download subdirs
FTDIR="Fasttrack"
BTDIR="BT"
# default file root
FILEROOT="$ROOTDIR/$INCOMING"

# dir for quarantining infected files, on same level as incoming, has to exist
QUARANTINE="quarantine"

# forcing commit in core, you might need to change "netcat" to "nc"
# depending on your distry, eg. Debian has nc and SuSE has netcat.
echo -e "commit\nq" | netcat localhost 4000

# lets figure out whether file came from ft or bt
# ugly but works
if test -e "$ROOTDIR/$INCOMING/$FTDIR/$FILENAME"; then
        FILEROOT="$ROOTDIR/$INCOMING/$FTDIR" ;
fi
if test -e "$ROOTDIR/$INCOMING/$BTDIR/$FILENAME"; then
        FILEROOT="$ROOTDIR/$INCOMING/$BTDIR" ;
fi

# if you experience problems uncomment follow line to compensate
# for a commit action that doesnt move but copy
#sleep 5

# scan the file check output of bdc for infected or suspicious files
# if found then quarantine else leave in incoming
if bdc --all --arc "$FILEROOT/$FILENAME" | grep ^[[S]].'''ect.'''files.*:[[1-9|I\]] > /dev/null; then
        mv "$FILEROOT/$FILENAME" "$ROOTDIR/$QUARANTINE/"
        echo "$EXECDATE  $FILENAME is bad. Moved to $ROOTDIR/$QUARANTINE" >> $ROOTDIR/scan.log;
   else
        echo "$EXECDATE  $FILENAME is ok. Left in $FILEROOT" >> $ROOTDIR/scan.log;
fi

# and exit properly
exit 0

Yet another virus scanning script

This one tries to be more resource friendly by skipping large files and files that should be considered safe, such as video files. It also tries to detect some fakes (currently only misnamed RAR and ZIP archives), and moves them to a quarantine folder (without scanning them). Requires the Z shell. (Warning, the script is not thoroughly tested yet)

#!/bin/zsh
# Warning! This script assumes you are running mldonkey > 2.7.0 where the
# file_completed_cmd is run after the file is committed, and the arguments are
# passed as environment variables

# Change the following variables to customize for your needs
MAXSIZE=1073741824             # 1GB
SAFE_TYPES=(ISO RIFF MPEG MP3) # these are matched against `file -b | awk '{print $1}'`
DATE="date +'%x [%T]: '"       # timestamps for the logfile
LOGFILE="/data/scan.log"       # location of the logfile
QUARANTINE="/data/quarantine"  # location of quarantine folder
CLAMAVOPTS="-r --tgz --unzip --unrar --jar --tar --lha --no-summary --stdout"


FILEPATH="$INCOMING/$FILENAME"

function log {
	print -- "$(eval $DATE) $@" >> $LOGFILE
}

function filter_size {
	if [[ $FILESIZE -ge $MAXSIZE ]] ; then
		log "filter_size($FILESIZE) SKIPPED $FILENAME"
		return 1
	fi
	return 0
}

function filter_type {
	FILETYPE=$(file -b $FILEPATH | awk '{print $1}')
	for t in $SAFE_TYPES ; do
		if [[ $FILETYPE == $t ]]; then
			log "filter_type($FILETYPE) SKIPPED $FILENAME"
			return 1
		fi
	done
	return 0
}

# Find files that aren't what they say they are (currently detects .rar and .zip fakes
function check_suffix {
	suffix=${FILENAME:e:l}
	for s in $@; do
		if [[ $suffix == $s ]]; then return 0; fi
	done
	return 1
}

function filter_fake {
	FILETYPE=$(file -b $FILEPATH | awk '{print $1}')
	if (check_suffix 'rar' && [[ $FILETYPE != "RAR" ]]) \
	 ||(check_suffix 'zip' && [[ $FILETYPE != "Zip" ]]) ; then
		log "filter_fake($FILETYPE) QUARN $FILENAME"
		mv -- "$FILEPATH" "$QUARANTINE"
		return 1
	fi
	return 0		
}

if filter_fake && filter_size && filter_type ; then
	eval "clamscan $CLAMAVOPTS "$FILEPATH"" >> $LOGFILE
	if [[ $? != 0 ]] ; then
		log "clamscan(INFECTED) QUARN $FILENAME"
		mv -- "$FILEPATH" "$QUARANTINE"
	fi
fi

Dispatching completed files to several directories

A more complex script for dispatching completed files on several directories, if you have several partitions (don't forget to share them all!):

#!/bin/bash
# file_completed_cmd interface
HASH="$1"
SIZE="$2"
FILENAME="$3"

INCOMING="incoming"
DIRS="/disk1/incoming /disk2/incoming"
MINFREEKB=1024

export LC_ALL=C
SIZEKB=$[[(SIZE+1023)/1024]]
REQUIREDKB=$[[SIZEKB+MINFREEKB]]

# not necessary with auto_commit = true
#echo -e "commit\nq"|nc localhost 4000

for dir in $DIRS; do
  DIRFREEKB=$(df -k "$dir" | gawk 'NR > 1 { print $4 }')
  if [[ $DIRFREEKB -ge $REQUIREDKB ]]; then
    mv "$INCOMING/$FILENAME" "$dir" && exit
  fi
done
# no free space, keep file in incoming

Also this is a perl script that moves file to specific directory according to its extension.

#!/usr/bin/perl
use strict;
use File::Basename;

# file_completed_cmd interface
my ($hash, $size, $file) = @ARGV;
exit if !$hash || !$size || !$file;

my $incoming='/home/mldonkey/incoming/';
my $minfreekb=1024;

# Define extensions here !!!

my %dispatch = (
# video
   '.avi .mpg .mpeg .wmv .divx' => '/var/ftp/incoming/mldonkey/',
# image
   '.iso .bin .cue' => '/var/ftp/incoming/mldonkey/',
# soft
   '.sh .exe .gz .bz2 .tar .tgz' => '/var/ftp/pub/mldonkey/',
# audio
   '.mp3 .wma .ogg .mod .xm' => '/var/ftp/pub/mldonkey/',
);

my $sizekb=($size+1023)/1024;
my $requiredkb=$sizekb+$minfreekb;

sub enough_space {
    my ($dir) = @_;
    my $dirfreekb = -1;
    if(open(DF, "df -k $dir|")) {
      my $headers = <DF>;
      my $line = <DF>; chomp $line;
      close DF;
      $dirfreekb = ( split(/[[ \t]]+/, $line) )[[3]] if defined $line;
    }
    $dirfreekb >= $requiredkb;
}

sub move_if_ok {
    my ($file, $dir) = @_;
    enough_space($dir) && system ('mv', $file, $dir) <code></code> 0
}

my $ext = (fileparse($file, '\.[[^.]]+$'))[[2]];
while(my ($exts, $extdir) = each %dispatch) {
  my @exts = split / +/, $exts;
  if((grep { $_ eq $ext } @exts) > 0) {
    move_if_ok($incoming.$file, $extdir) && last
  }
}

MLdonkey has already builtin features for auto commiting files (since 2.04), sending an email, or sending a notification to MLchat client, when a file is completed, see below.

COMMENT: methinks the name of this option is misleading. Firstly, it sounds like it's asking for the command line which is going to be executed when a file gets "completed", so I filled it with "/usr/bin/myNotifierApp $FILENAME finished!". Perhaps the option should be called file_completed_script or some such. And secondly: given the new (2.7.1's post-commit) behaviour of this option, perhaps it should be called file_commited_cmd. Or surely that could be a new option, leaving file_completed_cmd with its original purpose (i.e., pre-commit) and limitations.

Dispatch downloaded files using users as filter.

I'm using one MLDonkey core in a home network, around 6 users. And I want to protect privacy, then I had to have separated incoming files. The problem is when the destination disk is full, the file stays in incoming.

#!/bin/bash
# you need netcat and clamav (http://www.clamav.net) package

# file_completed_cmd interface
HASH="$1"
SIZE="$2"
FILENAME="$3"

# some handy variables
ROOTDIR="/home/mldonkey/.mldonkey"
ADMININC="incoming"
PAPAINC="/home/parents/papa/"
MAMAINC="/home/parents/Downloads"
IGNACIOINC="/home/ignacio"
DAVIDINC="/home/david"
DrEaMuXINC="/home/dreamux/Incoming"
DrEaMuX="/home/dreamux"
TIMENOW=`date`

# dir for quarantining infected files, on same level as incoming. See bottom of this script.
QUARANTINE="incoming/QUARENTENA"

# lets figure out wheather file came from
if test -e "$ROOTDIR/incoming/files/$FILENAME"; then
        INCOMING="incoming/files"
fi
if test -e "$ROOTDIR/incoming/directories/$FILENAME"; then
        INCOMING="incoming/directories"
fi
# This moves all files that are infected
# or caused clamscan to throw an error to quarantine directory.
# Hint: Better make the if line one line only.
# to use this feature uncomment lines below and comment the above

echo -en "\e[1;33m########################################## "${TIMENOW}" ###########################################\e[0m" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log
if echo ""; clamscan -r --tgz --unzip --unrar --jar --tar --lha --no-summary --stdout "$ROOTDIR/$INCOMING/$FILENAME" >> $ROOTDIR/scan.log; then
chmod 775 "$ROOTDIR/$INCOMING/$FILENAME"
if test "$FILE_OWNER" == "papa"; then
        chmod 755 -R "$ROOTDIR/$INCOMING/$FILENAME"
        chown papa:mldonkey "$ROOTDIR/$INCOMING/$FILENAME"
        mv "$ROOTDIR/$INCOMING/$FILENAME" "${PAPAINC}"
        echo -en "\e[1;32m$FILENAME\e[0m left in \e[1;34m"${PAPAINC}"\e[0m" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log
fi

if test "$FILE_OWNER" == "ignacio"; then
#       chmod 755 -R "$ROOTDIR/$INCOMING/$FILENAME"
        chown ignacio:mldonkey "$ROOTDIR/$INCOMING/$FILENAME"
        mv "$ROOTDIR/$INCOMING/$FILENAME" "${IGNACIOINC}"
        echo -en "\e[1;32m$FILENAME\e[0m left in \e[1;34m"${IGNACIOINC}"\e[0m" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log
fi

if test "$FILE_OWNER" == "david"; then
        chmod 755 -R "$ROOTDIR/$INCOMING/$FILENAME"
        chown david:mldonkey "$ROOTDIR/$INCOMING/$FILENAME"
        mv "$ROOTDIR/$INCOMING/$FILENAME" "${DAVIDINC}"
        echo -en "\e[1;32m$FILENAME\e[0m left in \e[1;34m"${DAVIDINC}"\e[0m" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log
fi

if test "$FILE_OWNER" == "mama"; then
        chmod 755 -R "$ROOTDIR/$INCOMING/$FILENAME"
        chown mama:mldonkey "$ROOTDIR/$INCOMING/$FILENAME"
        mv "$ROOTDIR/$INCOMING/$FILENAME" "${MAMAINC}"
        echo -en "\e[1;32m$FILENAME\e[0m left in \e[1;34m"${MAMAINC}"\e[0m" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log
fi
if test "$FILE_OWNER" == "dreamux"; then
        chmod 755 -R "$ROOTDIR/$INCOMING/$FILENAME"
        chown dreamux:mldonkey "$ROOTDIR/$INCOMING/$FILENAME"
        mv "$ROOTDIR/$INCOMING/$FILENAME" "${DrEaMuXINC}"
        echo -en "\e[1;32m$FILENAME\e[0m left in \e[1;34m"${DrEaMuX}"\e[0m" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log
fi

else
        mv "$ROOTDIR/$INCOMING/$FILENAME" "$ROOTDIR/$QUARANTINE/"
        chmod 777 -R "$ROOTDIR/$QUARANTINE/$FILENAME"
        echo -en "\e[1;31m$FILENAME\e[0m moved to \e[1;34m$ROOTDIR/$QUARANTINE\e[0m" >> $ROOTDIR/scan.log; echo -en "" >> $ROOTDIR/scan.log

fi
echo -en "\e[1;33m########################################## "${TIMENOW}" ###########################################\e[0m" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log
echo -en "" >> $ROOTDIR/scan.log; echo "" >> $ROOTDIR/scan.log;
#

It works pretty good.

Logging downloads, displaying duration, etc

Using the latest environment variables.

#!/usr/bin/env perl
# -.- by eydaimon -.-
use POSIX;
use strict;
use warnings;


#variables
# ("TEMPNAME",  temp_name);
# ("FILEID",    file_id);
# ("FILESIZE",  size);
# ("FILENAME",  filename);
# ("FILEHASH",  string_of_uids info.G.file_uids);
# ("DURATION",  duration);
# ("INCOMING",  incoming);
# ("NETWORK",   network.network_name);
# ("ED2K_HASH", ed2k_hash)]
#

my $IN_FILE="$ENV{INCOMING}/$ENV{FILENAME}";

my $FILETYPE=`file -b "$IN_FILE"`;
my $FILESIZE=nicefilesize($ENV{FILESIZE});
my $DATE=`date`;
my $DURATION = s_to_long($ENV{DURATION});
my $RATE = rate();
chomp $FILESIZE;
chomp $FILETYPE;
chomp $DATE;
my $donkey = "";
if ($ENV{NETWORK} eq "Donkey") {
$donkey = qq|
</tr><tr>
<td  class=heading>ED2Khash:
<td class=ed2khash><a href="$ENV{ED2K_HASH}">link</a>
|;
}

my $outfile = "file_completed_cmd_log.html";
if (! -f  $outfile) {
    open FH, ">$outfile";
    print FH $_ for (<DATA>);
} else { open FH, ">>$outfile"; }

print FH qq|
<div class=table><span class=raised>$DATE</span>
<table><tr>
<td class=heading>Filename:
<td class=filename>$ENV{FILENAME}
</tr><tr>
<td class=heading>Filetype:
<td class=filetype>$FILETYPE
</tr><tr>
<td class=heading>Filesize:
<td class=filesize>$FILESIZE
</tr><tr>
<td class=heading>Duration:
<td class=duration>$DURATION
</tr><tr>
<td class=heading>Rate:
<td class=duration>$RATE
</tr><tr>
<td  class=heading>Network:
<td class=network>$ENV{NETWORK}
</tr><tr>
<td  class=heading>Fileid:
<td class=filesid>$ENV{FILEID}
$donkey
</tr>
</table>
</div>
<br><p>
|;
close FH;

sub s_to_long {
    my ($secs) = @_;
    my $days = int($secs / 24 / 60 /60);
    return strftime "${days}d %Hh %Mm %Ss",$secs,0,0,0,0,0,0;
}
sub rate {
    my $kbs = $ENV{FILESIZE}/1024;
    return sprintf "%0.2f Kb/sec", $kbs/$ENV{DURATION};
}


sub nicefilesize {                                            
    my ($fs) = @_;
    my @ext = qw(b Kb Mb Gb Tb Pb);
    my $n=0; while($fs!~/^0./) { $fs/=1024; $n++; }
    $fs *= 1024; $n--;
    return sprintf "%0.2f$ext[$n]",$fs;
}

__DATA__
<STYLE TYPE="text/css">
.float {
    position: fixed;
    left: auto;
    top: 140px;
    right: 2px;
}
.date {
font-weight: bold;
color: blue;
}
.filename {
color: magenta;
}
.filetype {
color: green;
}
.filesize {
color: black;
}
  body {
      background-color: #8080B0;
      font-family: arial;
            /*
            margin-left : 10% ! important;
            margin-right : 10% ! important;
            margin-bottom : 10px ! important;
            margin-top : 10px ! important;
            */
  }
    .raised {
        font-family: arial;
        border: ridge black 2px;
        position: relative;
        top: -12px;
        left: 12px;
        padding: 4px;
        background:#afafdf;
        font-size: 13px;
        font-weight: bold;
        color: black;
    }
  .table {
      background-color: #ddf;
      margin-top: 15px;
         border: ridge black 3px;
  }
  .me { font-size: 10pt; color: red }
  .them { font-size: 10pt; color: blue }
  .time { font-size: 10pt; color: black }
  .msg { font-size: 10pt; color: black }
  .heading { font-weight: bold; font-size: 12pt; color: black }
  .caption {
      font-weight: bold; text-align: left; font-size: 12pt; color: black;
      background: #7fffd4;
  }
</STYLE>

Logging downloads into MySQL database

This script will insert into MySQL database the following fields: filename, filetype, filesize, duration, end, rate, network, hash, ed2klink, fileowner, filegroup.

MySQL table:

CREATE TABLE `mldonkey` (
  `index` int(11) NOT NULL auto_increment,
  `filename` varchar(255) NOT NULL,
  `filetype` varchar(255) default NULL,
  `filesize` bigint(20) default NULL,
  `duration` int(11) default NULL,
  `end` int(11) default NULL,
  `rate` int(11) default NULL,
  `network` varchar(30) default NULL,
  `hash` varchar(50) default NULL,
  `ed2klink` varchar(255) default NULL,
  `fileowner` varchar(50) default NULL,
  `filegroup` varchar(50) default NULL,
  PRIMARY KEY  (`index`)
) ENGINE=MyISAM;

PHP script which fills the MySQL table:

#!/usr/bin/env php

<?php
$host = 'localhost';
$dbname = 'mldonkey';
$dbuser = 'mldonkey';
$dbpass = '';

$path = $_ENV['INCOMING'] . "/" . $_ENV['FILENAME'];
$fileowner = $_ENV['FILE_OWNER'];
$filegroup = $_ENV['FILE_GROUP'];

$filename = htmlentities($_ENV['FILENAME'], ENT_QUOTES);
$filetype = htmlentities(`file -b "$path"`, ENT_QUOTES);
$filesize = $_ENV['FILESIZE'];
$end = time();
$duration = $_ENV['DURATION'];

$rate = ($_ENV['FILESIZE'] / $_ENV['DURATION']);
$network = $_ENV['NETWORK'];
$hash = substr($_ENV['FILEID'], 9, 32);
if ($network == "Donkey") {
    $ed2klink = $_ENV['ED2K_HASH'];
}

$connect = mysql_connect($hostname, $dbuser, $dbpass) or die (mysql_error());
mysql_select_db($dbname, $connect);
$insert = "INSERT INTO mldonkey (filename, filetype, filesize, duration, end, rate, network, hash, ed2klink, fileowner, filegroup) VALUES ('$filename', '$filetype', '$filesize', '$duration', '$end', '$rate', '$network', '$hash', '$ed2klink', '$fileowner', '$filegroup')";
$results = mysql_query($insert) or die(mysql_error());
mysql_close($connect);
?>

Logging downloads into SQLite database

#!/bin/bash
DB="$( dirname $0)/$( basename $0).db.sqlite3" 
SQLITE="sqlite3"
SQL="$SQLITE $DB"

if [ ! -e "$DB" ]
then
        echo "DB doesn't exist.. Creating it"
        $SQL "CREATE TABLE downloaded (TIME TEXT, TEMPNAME TEXT, FILEID TEXT, FILESIZE NUMERIC, FILENAME TEXT, \
          FILEHASH TEXT, DURATION NUMERIC, INCOMING TEXT, NETWORK TEXT, ED2K_HASH TEXT, DLFILES NUMERIC, \
          FILE_OWNER TEXT, FILE_GROUP TEXT);" && echo "successfully created DB"
fi


echo "inserting record into database"
$SQL "INSERT INTO downloaded ( TIME, TEMPNAME, FILEID, FILESIZE, FILENAME, FILEHASH, DURATION, INCOMING, \
      NETWORK, ED2K_HASH, DLFILES, FILE_OWNER, FILE_GROUP ) VALUES ( datetime('now'), \"$TEMPNAME\", \
      \"$FILEID\", \"$FILESIZE\", \"$FILENAME\", \"$FILEHASH\", \"$DURATION\", \"$INCOMING\", \"$NETWORK\", \
      \"$ED2K_HASH\", \"$DLFILES\", \"$FILE_OWNER\", \"$FILE_GROUP\"  ); "

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox