*nix Thread, using variables in wget etc in Technical; i have a cron script that tars up some stuff to a tar file that appends the days date to ...
30th July 2008, 03:30 AM #1
using variables in wget etc
i have a cron script that tars up some stuff to a tar file that appends the days date to the filename, and then uploads it offsite
Works great, uploads fine
tar -cf backup_`date +%Y-%m-%d`.tar /home
perl ftpput.pl --user=username --pass=password7 --dir=backup --binary --server=ftp.backup.com backup_`date +%Y-%m-%d`.tar
However on another location, Im trying to grab that file, and extract it, but wget doesnt seem to like the date variable and comes back with a 404
Is there any way of using wget with a date variable like that?
02:28:09 ERROR 404: Not Found.
(wasnt sure to post this in linux or scripting forum so plz move if needed)
Last edited by RabbieBurns; 30th July 2008 at 03:33 AM.
IDG Tech News
30th July 2008, 08:22 AM #2
I hit this kind of hurdle too and found it easier (read: saner) to use sftp for security and because you can script in a job.
I'll have a think on the wget one this morning.
30th July 2008, 09:30 AM #3
Ah, having looked at it, your wget is incorrectly laid out for the date. (needs a space between date and +).
wget http://wwww.backup.com/backup_`date +%Y-%m-%d`.tar
Also worth bearing in mind, if you're running/grabbing back ups over timezones/midnight be careful of the change of date! Kept me amused for a few hours working that one out.
Thanks to kmount from:
RabbieBurns (31st July 2008)
30th July 2008, 09:43 AM #4
Don't forget the -c (valuable in regards to lost packets and download stopping)
Could CTRL+C a long download with the -c switch, retype the exact command, and it will continue from where it left off!
Thanks to ahuxham from:
RabbieBurns (1st August 2008)
30th July 2008, 10:22 AM #5
Variable expansion has nothing to do with wget. It is done by the shell before the parameter (in this case a url) is passed to the program being called (in this case wget). I suggest you replace the wget command with an echo, then you can inspect the variable expansion and check that it is correct. If there's still something strange going on, add a 'set +x' to the beginning of your script and observe the output when you run the script manually.
Thanks to Geoff from:
RabbieBurns (31st July 2008)
31st July 2008, 06:38 PM #6
Thanks kmount for pointing out the missing space, and geoff for clarifying things, but it has taken me till now to realise i put wwww instead of www and that was another reason why it wasnt working
All working now No timezones to worry about, but thanks for the tip.
31st July 2008, 10:23 PM #7
rsync and rdiff-backup 4tw
Take a look at those, they rock.
(I know it's a troll pic, but it DANCES!)
By techyphil in forum Windows
Last Post: 23rd May 2008, 04:09 PM
By gibbo_ap in forum Web Development
Last Post: 24th April 2008, 03:48 PM
By HodgeHi in forum Scripts
Last Post: 21st June 2006, 10:05 AM
By Frazer in forum Windows
Last Post: 10th October 2005, 11:12 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)