linux - Echo the current file transfer with LFTP -
i'm trying echo $file_name once transfer complete. cannot find reference how create variable in lftp displays file name of downloaded.
the code:
#!/bin/bash login="myusername" pass="notmypassword" host="my.hosting.server" remote_dir='/path/to/remote/dir/.' local_dir="/path/to/local/dir/" file_name=**the name of file im downloading** base_name="$(basename "$0")" lock_file="/tmp/$base_name.lock" trap "rm -f $lock_file" sigint sigterm if [ -e "$lock_file" ] echo "$base_name running already." exit else touch "$lock_file" lftp -u $login,$pass $host << eof set ftp:ssl-allow no set mirror:use-pget-n 5 mirror -c -x "\.r(a|[0-9])(r|[0-9])$" -p5 --log="/var/log/$base_name.log" "$remote_dir" "$local_dir" echo $file_name quit eof #osascript -e 'display notification "$file_name downloaded" title "media server"' rm -f "$lock_file" trap - sigint sigterm exit fi
i figured rather simple echo current file , add variable osascript trigger notification on osx file has been transferred, life of me can't figure out how.
what doing wrong???
cheers!
this script echo each file transferred, feel free clean , modify suit needs:
#!/bin/bash echo "script started." download_directory="${home}/downloads/" echo "downloading ${download_directory}" rm ${download_directory}/* download_log=$(mktemp) lftp <<- eof > ${download_log} # elided connection details, enter own open mirror -v . ${download_directory} quit eof cat ${download_log} | awk ' { print $3 } ' | sed 's/`//' | sed 's/'\''//' | xargs echo "downloaded:" rm -f ${download_log} echo "script ended."
example output:
=> ./foobar.sh script started. downloading /home/downloads/ downloaded: something1.yes testfile.txt script ended.
Comments
Post a Comment