The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
crontab + exec command naushad Shell Programming and Scripting 4 03-27-2008 12:23 AM
Help with exec command and file descriptors?? rfourn Shell Programming and Scripting 1 07-18-2007 03:05 PM
find command exec error pavan_test UNIX for Dummies Questions & Answers 2 06-13-2006 12:58 AM
exec command g_s_r_c Shell Programming and Scripting 1 09-20-2004 09:20 AM
using the -exec command moxxx68 UNIX for Dummies Questions & Answers 0 04-13-2004 11:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #22  
Old 09-09-2008
Registered User
 

Join Date: Apr 2008
Location: Calgary
Posts: 196
Oddly enough, I was able to get this to work without any problems
Code:
#!/usr/bin/ksh

find dir1/dir2 -type f -name "FILE.*" -newer dir1/dir2/afterme.txt -exec cp {} dir1/dir2/dir3 \;
Reply With Quote
Forum Sponsor
  #23  
Old 09-09-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
Quote:
Originally Posted by jim mcnamara View Post
type
Code:
which bash
What does it give you? Exactly.

What I see so far is a PATH problem or somebody installing the OS incorrectly, or some type of chrooted account. Note: are you in school - like a secondary school and using a restricted unix or student account?
The result of the above code is: /bin/bash

No I'm not in school. This is a live environment and I'm putting scripts in place to move files around. These exact scripts works on other servers but not this one.
Reply With Quote
  #24  
Old 09-09-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
Quote:
Originally Posted by avronius View Post
Oddly enough, I was able to get this to work without any problems
Code:
#!/usr/bin/ksh

find dir1/dir2 -type f -name "FILE.*" -newer dir1/dir2/afterme.txt -exec cp {} dir1/dir2/dir3 \;

It works if I type it manually. But put it in a script and no go.
Reply With Quote
  #25  
Old 09-09-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
Oh and I'm running these commands are root, if that makes a difference.
Reply With Quote
  #26  
Old 09-09-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
This is hard for all of us:
what does
Code:
echo $PATH
show?

Are you running the script in cron?
Reply With Quote
  #27  
Old 09-09-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
Quote:
Originally Posted by jim mcnamara View Post
This is hard for all of us:
what does
Code:
echo $PATH
show?

Are you running the script in cron?
The result from "echo $PATH" is: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

I'm testing it first using the ./scriptname command. Once it works there, then I'll put it in cron.
Reply With Quote
  #28  
Old 09-09-2008
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,262
This sure looks weird.

To sum up what we know so far:

OS: RedHat
Shell: bash
User: root
no chrooted environment, no special non-printing characters.

First observation: the paths in the script are not absolute paths. This might lead to no directories/files being found when the script is executed in a wrong current path. Change these paths to absolute paths to make the script more robust.

Here is another take at problem determination: modify your script by switching on printing of the interpreted lines:

Code:
#!/bin/bash

set -xv      # <--- makes every line being printed to stdout after parsing

fRootDir="/some/path"   # set an absolute starting path

find $fRootDir/dir1/dir2 -type f -name "FILE.*" -newer $fRootDir/dir1/dir2/afterme.txt -exec cp {} $fRootDir/dir1/dir2/dir3 \;

exit 0
Now start the script this way:

Code:
root@server # ./myscript.sh 2> myscript.log
and post the contents of the file myscript.log here. I would really be interested in what the problem is here and what the final solution will be.

I hope this helps.

bakunin
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0