Shell script problems with Leopard. Please help urgently!

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

  1. yellowtip macrumors newbie

    Jun 11, 2007
    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

    Jun 11, 2007
    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

    Jun 16, 2004
    If you look at your Apple discussion thread, someone responded:
    date -v-1d
    date -v-7d

    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

    Jun 11, 2007
    Thanks for the reply!

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


Share This Page