Sponsored Content
Top Forums Shell Programming and Scripting 'unexpected token' error using FIND in script to delete old files Post 302418285 by rpalmer68 on Monday 3rd of May 2010 05:49:19 PM
Old 05-03-2010
'unexpected token' error using FIND in script to delete old files

Hi,

I am compete linux noob, but have managed to setup my Thecus N5500 to rsync to my N5200Pro to do automatic backups each night.

The rsync script also moves any files deleted from the N5500 (and previously backed up to the N5200) to a _deleted folder on the N5200 so I can keep them for 30 days before removing them.

This is where I have run into a problem....

I have the following script that I run on the N5200;
Code:
#!/bin/bash
## This script will delete files older than 30 days from the deleted backups
## generated by nas_backup.sh on NAS1
find /raid0/data/nas_backup/media_deleted/* -mtime +30 -exec rm -f '{}' \;

The problem is I'm getting errors like these when I run the script;
Quote:
root@127.0.0.1:/raid0/data/nsync# sh delete30days.sh
rm: /raid0/data/nas_backup/media_deleted/Library: is a directory
rm: /raid0/data/nas_backup/media_deleted/Library/Master/Cache: is a directory
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `rm -f /raid0/data/nas_backup/media_deleted/Library/Master/Cache/File List Sort/Cache (62).dat'

I don't know if it's any help, but I did have to enclose the {} in quotes '{}' otherwise I got issues with spaces in the directory names as well, which there seems to be great debate in other threads if this is required of not.


I'm not sure what release/version on linux is on the thecus N5200 but I did get this from the box;
Quote:
root@127.0.0.1:/raid0/data/nsync# uname -r
2.6.23N5200
root@127.0.0.1:/raid0/data/nsync# uname -a
Linux nasbackup 2.6.23N5200 #13 Thu May 14 12:47:37 CST 2009 i686 unknown
root@:~# bash -version
GNU bash, version 3.00.16(2)-release (i486-slackware-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
if it's any help.



Can anybody suggest how to fix this please?

Thanks
Richard
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

While loop error: Unexpected token done

I have tried to implement a while loop into the code but upon running the following code i am getting the errors: ./Assigntest: line 42: syntax error near unexpected token `done' ./Assigntest: line 42: `done' The code is as follows: #!/bin/bash #Filename: Assignment Author: Luke... (9 Replies)
Discussion started by: warlock129
9 Replies

2. Shell Programming and Scripting

Syntax error near unexpected token `('

Guys , This is an output of my script errored out for "Syntax error near unexpected token `(' " Can someone tell me whats wrong with my script. Below is my original script pasted. #!/bin/bash Script Creation Date 01/21/2010 Author baraghun ... (7 Replies)
Discussion started by: raghunsi
7 Replies

3. UNIX for Advanced & Expert Users

syntax error near unexpected token '{

Hi, I am running the following script through cygwin and getting below mentioned error. ******************************************* #!/bin/sh # constants WORK_DIR="deploy" INFOFILE="deploy.info" INTROFILE="Intro.sh" CMGMT_PKG="com.kintana.cmgmt.deploy" DEPLOY_PREFIX="mitg" ... (2 Replies)
Discussion started by: MandyR
2 Replies

4. Shell Programming and Scripting

Unexpected Token Error `;;'

Hello all, Im having an Issue with my script for switch statement , can someone let me know where do i need to correct it. 7 ##******************************************************************************************************* 8 ## ********** FUNCTION USAGE *********** ... (13 Replies)
Discussion started by: raghunsi
13 Replies

5. UNIX for Dummies Questions & Answers

Syntax error near unexpected token

hi! just want to seek help on this error: syntax error near unexpected token 'do this is my script # !/bin/sh # for y in 27 25 do exemmlmx -c "ZEEI;" -n XRT$y >> blah done what can be wrong? thanks! (6 Replies)
Discussion started by: engr.jay
6 Replies

6. Shell Programming and Scripting

syntax error near unexpected token `='

Hi all, This is a script which converts hex to bin. However am finding an error while executing syntax error near unexpected token `=' `($hexfile, $binfile) = @ARGV;' I am running using ./fil.pl <hexfile> <binfile> ################################################### # # this script... (3 Replies)
Discussion started by: jaango123
3 Replies

7. Shell Programming and Scripting

Syntax error near unexpected token `('

What do I do here? #!/bin/bash payload=-1 AND 1=IF(21,BENCHMARK(5000000,MD5(CHAR(115,113,108,109,97,112))),0)# hash=`echo -n $payload md5sum tr -d 'n' sed 'ss-sg' md5sum tr -d 'n' sed 'ss-sg'` curl --data cs2=chronopay&cs1=$payload&cs3=$hash&transaction_type=rebill... (2 Replies)
Discussion started by: iiiiiiiiiii
2 Replies

8. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

9. Shell Programming and Scripting

Syntax error near unexpected token `else'

Hi, I am trying to read the session log through script. But it keeps showing me some error near. I have tried everything. Even tried converting the script using sed command to remove the hidden characters(\r).But nothing seems to be working.Below is the script : #!/bin/bash cd... (6 Replies)
Discussion started by: Aryan12345
6 Replies

10. Shell Programming and Scripting

Syntax error near unexpected token `|'

Hi All; I try to write a bash code and I am using command substitution. My code is like: #!/bin/bash IP="10.0.0.1 10.0.0.2" PORT="22 80" USERNAME="admin" SCRIPT_HOST="adminHost" HOME_DIR=/home/admin SCRIPT_DIR=$HOME_DIR/scripts script="sudo /my_remote_script.sh" SSH="/usr/bin/ssh... (7 Replies)
Discussion started by: Meacham12
7 Replies
XmScrollVisible(library call)											     XmScrollVisible(library call)

NAME
XmScrollVisible -- A ScrolledWindow function that makes an invisible descendant of a ScrolledWindow work area visible SYNOPSIS
#include <Xm/ScrolledW.h> void XmScrollVisible( Widget scrollw_widget, Widget widget, Dimension left_right_margin, Dimension top_bottom_margin); DESCRIPTION
XmScrollVisible makes an obscured or partially obscured widget or gadget descendant of a ScrolledWindow work area visible. The function re- positions the work area and sets the specified margins between the widget and the nearest viewport boundary. The widget's location relative to the viewport determines whether one or both of the margins must be adjusted. This function requires that the XmNscrollingPolicy of the ScrolledWindow widget be set to XmAUTOMATIC. scrollw_widget Specifies the ID of the ScrolledWindow widget whose work area window contains an obscured descendant. widget Specifies the ID of the widget to be made visible. left_right_margin Specifies the margin to establish between the left or right edge of the widget and the associated edge of the viewport. This margin is established only if the widget must be moved horizontally to make it visible. top_bottom_margin Specifies the margin to establish between the top or bottom edge of the widget and the associated edge of the viewport. This margin is established only if the widget must be moved vertically to make it visible. For a complete definition of ScrolledWindow and its associated resources, see XmScrolledWindow(3) RELATED
XmScrolledWindow(3). XmScrollVisible(library call)
All times are GMT -4. The time now is 12:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy