#!/bin/bash

OUTPUT="$(date +%s)"
#echo $OUTPUT | tee /media/nas1/outputfile
sudo scanimage -L
sudo scanimage -d "airscan:e0:Brother MFC-J480DW" --format=tiff | convert tiff:- /media/nas1/scan$OUTPUT.jpg
echo "put /media/nas1/scan$OUTPUT.jpg" > /var/www/cadaverAction
echo "exit" >> /var/www/cadaverAction
 sudo -u neiyv cadaver -r /var/www/cadaverAction https://yvesneisiusfritzbox.hopto.org/owncloud/remote.php/dav/files/neiyv/ 

echo "<!DOCTYPE HTML>"

echo '<html lang="en-US">'
echo '<head>'
echo        '<meta charset="UTF-8">'
echo        '<meta http-equiv="refresh" content="0; url=https://yvesneisiusfritzbox.hopto.org/webdav">'
echo        '<script type="text/javascript">'
echo            'window.location.href = "https://yvesneisiusfritzbox.hopto.org/webdav"'
echo        '</script>'
echo        '<title>Page Redirection</title>'
echo    '</head>'
echo    '<body>'
     
echo    '</body>'
echo '</html>'
