Results 1 to 4 of 4
  1. #1

    small unix batch script question

    Hi-

    I am trying to implement a batch script under Sco Unix to copy a directory on the last day of a month. I found some code and keep getting an error on one line:

    Code:
    #create monthly backup of UB data
    # determine tomorrows day 1-31
    
    TOM=$(TZ=EDT-24 date +%d)
    
    if [ $TOM -eq 1 ]; then
       DATE=`date +%y%m%d`
       cd /usr2/archive/
       mkdir $DATE
       cd $DATE
       cp /usr2/mufiles2/muub* .
    fi
    the offending line is: "TOM=$(TZ=EDT-24 date +%d)"

    the script returns "syntax error at line 4: `TOM=$' unexpected"

    If I type "(TZ=EDT-24 date +%d)" at the command prompt, it returns '04' (tomorrow's day).

    Any help would be appreciated.

    Thanks,
    -Tom

  2. #2
    Is that the whole script? If so, you need to have "#!/bin/sh" at the top. ie:

    Code:
    #!/bin/sh
    
    #create monthly backup of UB data
    # determine tomorrows day 1-31
    
    TOM=$(TZ=EDT-24 date +%d)
    
    if [ $TOM -eq 1 ]; then
       DATE=`date +%y%m%d`
       cd /usr2/archive/
       mkdir $DATE
       cd $DATE
       cp /usr2/mufiles2/muub* .
    fi
    Dan - Vice President - [email protected]
    BurstNET Technologies - http://www.burst.net

  3. #3
    I though #!/bin/sh was a comment.

    I added it as the first line in the script but still get the exact same error message.

    -Tom

  4. #4
    Join Date
    Dec 2005
    Posts
    82
    Try to replace that string by
    -----------------------------------------
    TOM=`TZ=EDT-24 date +%d`;
    -----------------------------------------



Posting Permissions

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