+ Post New Thread
Results 1 to 7 of 7
*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 ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,512
    Thank Post
    1,320
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199

    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

    Code:
    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
    Works great, uploads fine

    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

    Code:
    wget http://wwww.backup.com/backup_`date+%Y-%m-%d`.tar
    02:28:09 ERROR 404: Not Found.
    Is there any way of using wget with a date variable like that?

    (wasnt sure to post this in linux or scripting forum so plz move if needed)
    Last edited by RabbieBurns; 30th July 2008 at 02:33 AM.

  2. #2


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,686
    Thank Post
    352
    Thanked 794 Times in 714 Posts
    Rep Power
    346
    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.

  3. #3


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,686
    Thank Post
    352
    Thanked 794 Times in 714 Posts
    Rep Power
    346
    Ah, having looked at it, your wget is incorrectly laid out for the date. (needs a space between date and +).

    Code:
    wget http://wwww.backup.com/backup_`date +%Y-%m-%d`.tar
    Works.

    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.

  4. Thanks to kmount from:

    RabbieBurns (31st July 2008)

  5. #4
    ahuxham's Avatar
    Join Date
    Apr 2008
    Posts
    1,122
    Thank Post
    76
    Thanked 138 Times in 109 Posts
    Rep Power
    30
    PHP Code:
    wget -
    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!

  6. Thanks to ahuxham from:

    RabbieBurns (1st August 2008)

  7. #5

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224
    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.

  8. Thanks to Geoff from:

    RabbieBurns (31st July 2008)

  9. #6

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,512
    Thank Post
    1,320
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    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.

  10. #7
    kesomir's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    288
    Thank Post
    15
    Thanked 28 Times in 23 Posts
    Rep Power
    17
    rsync and rdiff-backup 4tw

    Take a look at those, they rock.



    (I know it's a troll pic, but it DANCES!)

SHARE:
+ Post New Thread

Similar Threads

  1. TEMP and TMP variables Deleted?
    By techyphil in forum Windows
    Replies: 5
    Last Post: 23rd May 2008, 03:09 PM
  2. Server Variables on CC3
    By gibbo_ap in forum Web Development
    Replies: 2
    Last Post: 24th April 2008, 02:48 PM
  3. Environment variables or other method
    By HodgeHi in forum Scripts
    Replies: 3
    Last Post: 21st June 2006, 09:05 AM
  4. Replies: 4
    Last Post: 10th October 2005, 10:12 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •