Bash file...weird problem
I've created a sh file to delete a cache folder for one of my sites. Basically, the bash looks like this:
Code:
#!/bin/bash The cached folder has 0777 permissions all the time, owner root, group root. The funny part is, I have another site, on the same server, different account and this bash works perfectly. If I run the commands individually from the console, works perfectly... I'm puzzled ... Tnx in advance |
Try using full pathnames for your cached folder, such as:
/home/me/cached ...cause when you execute the shell, it does not use your pwd. |
If you try to echo the arguments, what do you think would it have expanded to?
Code:
echo rm -fdr cached* |
Quote:
As for the full path, it's the same thing, tried it now, same result. The sh file is in the root folder, where the dir cached resides. I've double checked permissions now, all seems ok, I don't rly get it, especially when the same command runs without problems under other account. |
Add a "pwd" to your script and pipe the output to a file.
pwd > foo.txt ...see where you're operating at the time you rm the directory. |
How 'bout if you remove the '-f' option. It might print the errors.
|
"The funny part is, I have another site, on the same server, different account and this bash works perfectly."
What do you mean by "another site"? Another path? Another account? You say it works with the other account, but what is fundamentally different in your account and the other? |
Try adding a comment after cached
Code:
mkdir cached # this is a comment |
Make your 'rm' command do the following:
rm -rdf cached* 2>&1 ...to see if errors are being thrown. |
I don't know how, but I bet you have a DOS line ending on that line and possibly others.
Does 'cat -A file' show Code:
mkdir cached^M$ |
Quote:
|
Quote:
|
Quote:
tnx alot guys for the help |
Don't know for sure if the "-f" switch negates this, but is your "rm" command aliased to "rm -i"? Try running "rm" like this:
/rm to see. |
I think you mean
\rm |
All times are GMT -5. The time now is 05:54 AM. |