Shell script problems with Leopard. Please help urgently!

Discussion in 'Mac Programming' started by yellowtip, Jan 19, 2008.

  1. yellowtip macrumors newbie

    Joined:
    Jun 11, 2007
    #1
    I have this really nice rsync backup script that I use to do rotating snapshot backups of my different Ubuntu servers to a single backup server.

    I am now trying to use this same script on my Leopard machine, but it seems to have a serious problem with the following lines of code:

    lday=`date +'image-%Y-%m-%d-%H' -d '1 day ago'`
    lweek=`date +'image-%Y-%m-%d-%H' -d '1 week ago'`

    The generate the following error:
    date: illegal time format
    usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

    It's clear that it doesn't like the -d '1 day ago' part in my code.

    Is this solved differently in Leopard?

    Could someone please help me out? I've be trying to research this for the past 8 hours, but can't seem to find any solution to this problem.

    Thanks in advance.
     
  2. yellowtip thread starter macrumors newbie

    Joined:
    Jun 11, 2007
    #2
    After almost 50 views does nobody have a clue about this issue?

    I'm no hardcore programmer, but I figure this 'date -d' function is a pretty regular thing. If it doesn't work, it would be a major flaw in the otherwise beautiful Leopard OS.

    Anybody...please????? :confused:
     
  3. sord macrumors 6502

    Joined:
    Jun 16, 2004
    #3
    If you look at your Apple discussion thread, someone responded:
    Code:
    date -v-1d
    date -v-7d
    (http://discussions.apple.com/thread.jspa?messageID=6388851)

    It should also be noted that UNIX and the BSDs do not have the -d parameter in the same way you want. It was an option that the Linux people added to Linux.
     
  4. yellowtip thread starter macrumors newbie

    Joined:
    Jun 11, 2007
    #4
    Thanks for the reply!

    Impressive how you found my thread in the Apple forums :)

    Thanks!
     

Share This Page