'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;
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.
And please refrain from wrongly thinking {} need to be quoted ...
Thanks for the quick response, the above code gives this error;
Quote:
find: option '-exec' requires an argument
And this code
gives the same error
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 +'
Cheers
Richard
Last edited by rpalmer68; 05-03-2010 at 07:38 PM..
What find version are you using ? It looks like it doesn't know the posix "+" exec delimiter. It looks too it used "sh -c" to run its exec command, which is quite unexpected.
Anyway, try this:
What find version are you using ? It looks like it doesn't know the posix "+" exec delimiter. It looks too it used "sh -c" to run its exec command, which is quite unexpected.
Anyway, try this:
This gives the same token error I'm afraid.
I'm calling the script with "sh delete30days.sh", I assume this is the correct way to call it?
How do I get the FIND version? find -? gives this;
Quote:
root@127.0.0.1:/raid0/data/nsync# find -?
BusyBox v1.1.0 (2009.03.26-08:00+0000) multi-call binary
Usage: find [PATH...] [EXPRESSION]
Search for files in a directory hierarchy. The default PATH is
the current directory; default EXPRESSION is '-print'
EXPRESSION may consist of:
-follow Dereference symbolic links
-name PATTERN File name (leading directories removed) matches PATTERN
-print Print (default and assumed)
-type X Filetype matches X (where X is one of: f,d,l,b,c,...)
-perm PERMS Permissions match any of (+NNN); all of (-NNN);
or exactly (NNN)
-mtime TIME Modified time is greater than (+N); less than (-N);
or exactly (N) days
-newer FILE Modified time is more recent than FILE's
-inum N File has inode number N
-exec CMD Execute CMD with all instances of {} replaced by the
files matching EXPRESSION
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)