[ZendTo] dropls - ls for dropoff folder

Der PCFreak mailinglists at pcfreak.de
Mon May 26 12:01:55 BST 2014


Hi,

I wanted to create some kind of "ls" command for the dropoff folder when 
I am logged on to the ZendTo machine in bash.

Here is my attempt. Works for me!

Add your username,database,dbpassword,dropoffbasefolder and put the 
script into PATH


#!/bin/bash
# dropls command by PCFreak
sqlu="zendto"
sqld="zendto"
sqlp="password"
dropoffbase="/var/zendto/dropoffs"
folder="$PWD"

# Check if we are in the dropoff folder
if [[ $PWD != $dropoffbase* ]];then   # True if $a starts with an "z" 
(wildcard matching).
  #echo "We are not in $dropoffbase or a subfolder of it!"
  #echo "Will exit"
  exit 1
fi


for a in $(find $folder/* -maxdepth 0 -exec basename {} \;); do

  # for dropoff folders
  if [[ -d "$PWD/$a" ]]; then
   email=$(echo select senderEmail from dropoff where claimID=\'$a\' \
   | mysql -B -N --user=$sqlu --password=$sqlp $sqld;)
   echo -e "$a\t$email"
  fi
  # for dropoffs in dropoff folders
  if [[ -f "$PWD/$a" ]]; then
   email=$(echo select senderEmail from dropoff where 
claimID=\'$(basename $PWD)\' \
   | mysql -B -N --user=$sqlu --password=$sqlp $sqld;)
   filename=$(echo select basename from file where tmpname=\'$a\' \
   | mysql -B -N --user=$sqlu --password=$sqlp $sqld;)
   echo -e "$a\t\"$filename\"\t$email"
  fi

done


Then just execute "dropls" when you are in your dropoffs folder with bash.

Kind regards

PCFreak



More information about the ZendTo mailing list