I had today the need to transfer a pdf (named on a date base) which I retrieve from a samba server every day from my intranet which is not accessible from outside to a more easily accessible webserver:
Problems:
- mount the samba server CLI (fstab)
- dont be asked for a password from the ftpserver (I will use the .netrc)
1st of all let's add the string needed to mount the volume in the fstab:
//x.x.x.x/remoteName /media/samba cifs username=alex,password=,uid=501,noauto 0 0where x.x.x.x is the address of the server
$ crontab -l0 8 * * * /home/alex/transfer.cron >/dev/null 2>&1
then write the script doing the retrieve so that it write the .ntrc with the correct file without transferring EVERYTHING everyday:
#!/bin/shNOME=`/bin/date --date "1 days ago" +"nome%Y%m%d.pdf"`cat /home/alex/.netrc_tmpl |sed -e "s%2BETRASFERRED%$NOME%">/home/alex/.netrcchown alex /home/alex/.netrcchmod 600 /home/alex/.netrcsudo umount /media/sambamount /media/sambaftp ftp.server.eu
based on :
>cat .netrc_tmplmachine ftp.server.eu login name@somewhere.it password xxxxxx macdefinitlcd /media/sambacd /listingprompt offbinmput 2BETRASFERREDquit
enjoy the reading after every breakfast
note: to change the date in the past or in the future refer to: http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html
custom solutions for everything
http://lxphotostudio.mine.nu
No comments:
Post a Comment