Sponsored Content
Top Forums Shell Programming and Scripting Script runs but does not execute rm -rf command Post 302772388 by MrBiggz on Monday 25th of February 2013 10:08:15 AM
Old 02-25-2013
Script runs but does not execute rm -rf command

Hi!

First off I'm no bin/bash script writer! Smilie I can make heads and tales of it from the php experience I have and that's all.

Now I managed to piece this script together to go look at directory and remove files that are +60 days. It's finding the files but its not removing them. I believe I have the command right.

Here's my script albeit short ..

Code:
#!/bin/bash
IFS=”$”
cpanel_username=*********
domain=ftsoccerclub.org 
username=mflores
cd /home/${cpanel_username}/mail/${domain}/${username}
find -P /home/${cpanel_username}/mail/${domain}/${username}/* -mindepth 1 -maxdepth 1 -mtime +60 | while read old; do
echo “Deleting ${old}…”
rm -rf “${old}”
done

and then I'll get an email from the server telling me ...

Code:
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1352080174.H191427P31791.aegis.provim.net,S=5532:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1352906954.H115090P16065.aegis.provim.net,S=17638:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1353454848.H164807P5507.aegis.provim.net,S=5482:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1352658395.H166861P17720.aegis.provim.net,S=23414:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1353519624.H550535P18176.aegis.provim.net,S=5236:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1352724748.H508350P20254.aegis.provim.net,S=23200:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1351785142.H117822P22505.aegis.provim.net,S=11548:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1352287307.H69509P3896.aegis.provim.net,S=26245:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1353537904.H596136P16093.aegis.provim.net,S=77013:2,…”
“Deleting /home/ftsoccer/mail/ftsoccerclub.org/mflores/cur/1352129497.H679409P15661.aegis.provim.net,S=15964:2,…”

and if I go back to that directory .. the file still stands! |=

The permission on the file(s) is 660

The cpanel username I use is like God on here so I don't think it's a permission issue .. then again I could be wrong!

Any help would be greatly appreciated!

Last edited by Scrutinizer; 02-25-2013 at 12:29 PM.. Reason: quote tags => code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to execute user command

I don't know why the following shell script doesn't work. Could you please help me out? #!/usr/bin/ksh test="cal > /tmp/tmp.txt 2>&1" $test I know it will work for the following format: #!/usr/bin/ksh cal > /tmp/tmp.txt 2>&1 However, I need to get the command from the user in... (1 Reply)
Discussion started by: redtiger
1 Replies

2. Shell Programming and Scripting

how to execute a sh command from a csh script

Hi everyone, I have a csh script that works fine but the output of an rsh command is different if I use boune shell instead cshell. Is there the possibility to execute only this command in bourne shell from a script declared cshell? Thanks Christian (2 Replies)
Discussion started by: bonovox
2 Replies

3. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

4. Shell Programming and Scripting

Shell script runs fine in Solaris, in Linux hangs at wait command

HI, I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging. here is the core of the script CFG_FILE=tab25.cfg sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" | while IFS="!" read a b c do #echo "jobs output" #jobs #echo "jobs... (13 Replies)
Discussion started by: aksaravanan
13 Replies

5. Shell Programming and Scripting

CRON shell script only runs correctly on command line

Hi, I'm new to these forums, and I'm hoping that someone can solve this problem... To make things short: I have DD-wrt set up on a router. I'm trying to run a script in CRON that fetches the daily password from my database using SSH. CRON is set like so(in web interface): * * * *... (4 Replies)
Discussion started by: louieaw
4 Replies

6. UNIX for Dummies Questions & Answers

How to execute command after telneting in shell script?

Hi , I have to write a shell script to telnet to specific host and execute the admin command there. Please help me to do that. Eg : telnet hostname portno admin command exit (3 Replies)
Discussion started by: arukuku
3 Replies

7. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

8. Shell Programming and Scripting

Script runs in command-line fine but times out in CRON?

Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out. They both start and run fine, but on the CRON it stops prematurely. The script hits an API every few seconds and grabs data. Does anyone have any idea on... (4 Replies)
Discussion started by: phpchick
4 Replies

9. Shell Programming and Scripting

Sql command inside shell script runs without giving anything back as outout

#!/bin/sh # This script returns the number of rows updated from a function echo "The execution is starting ....." sqlplus -silent $UP <<EOF set serveroutput on set echo off set pagesize 0 VAR no_rows_updated NUMBER; EXEC :no_rows_updated :=0; DECLARE CURSOR c_update is SELECT * FROM... (4 Replies)
Discussion started by: LoneRanger
4 Replies

10. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies
SHTOOL-PATH.TMP(1)					      GNU Portable Shell Tool						SHTOOL-PATH.TMP(1)

NAME
shtool-path - GNU shtool command dealing with shell path variables SYNOPSIS
shtool path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path path] str [str ...] DESCRIPTION
This command deals with shell $PATH variables. It can find a program through one or more filenames given by one or more str arguments. It prints the absolute filesystem path to the program displayed on "stdout" plus an exit code of 0 if it was really found. OPTIONS
The following command line options are available. -s, --suppress Supress output. Useful to only test whether a program exists with the help of the return code. -r, --reverse Transform a forward path to a subdirectory into a reverse path. -d, --dirname Output the directory name of str. -b, --basename Output the base name of str. -m, --magic Enable advanced magic search for ""perl"" and ""cpp"". -p, --path path Search in path. Default is to search in $PATH. EXAMPLE
# shell script awk=`shtool path -p "${PATH}:." gawk nawk awk` perl=`shtool path -m perl` cpp=`shtool path -m cpp` revpath=`shtool path -r path/to/subdir` HISTORY
The GNU shtool path command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Apache. It was later taken over into GNU shtool. SEE ALSO
shtool(1), which(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-PATH.TMP(1)
All times are GMT -4. The time now is 11:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy