IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New this bash script is driving me nuts foo is the name of the directory I want to play with
when I run the component parts at the command line it works fine. Any ideas?
When I run the script I get a permission denied with the path of the file I am trying to move. I am running this as root. root owns the directory I am moving to.


****************************
#!/bin/bash

export homedir='/home/sftp'

echo $homedir

ls $homedir | grep foo >/tmp/foo

while read -r line

do

if $homedir/$line$homedir/$line/*; then mv `find $homedir/$line$homedir/$line -type f -print | egrep -v '^dev|etc|lib|libexec|out|proc|selinux|tmp|usr|vari|bin|.ssh'` $homedir/$line ; echo $line `ls $homedir/$line` >>/var/log/mvftp.log; else echo $line'no files to move' >>/tmp/ftpmv.out; fi

done
always look out for number one and don't step in number two
New Yuck. Give me perl!
Break that find into a redirection to get a list of files to move. Then echo each file name/command as you are doing it. That will point you to the problem file.
New I will try that, thanks
always look out for number one and don't step in number two
New The problem is with the if
Assuming you're trying to figure out if the $line subdir is non-empty, try this:

if [ -n "$(ls -A $homedir/$line$homedir/$line)" ]; then

"if * then" ends up attempting to execute the files in that subdir. If one does not have the execute bit set, you'll get the Access Denied. Even if it worked, it would not find .files, which it looks like you're interested in given the presence of .ssh in the egrep pattern.
New saved once again by someone who is not a duffer, thank you
thought the then would only execute the mv command. I am excluding the .ssh directory.
always look out for number one and don't step in number two
New Welcome. You can scratch all the dirs from egrep
The preceding find -type f already excludes all directories.
New I didnt want the files in those directories moved
always look out for number one and don't step in number two
     this bash script is driving me nuts foo is the name of the directory I want to play with - (boxley) - (6)
         Yuck. Give me perl! - (crazy) - (1)
             I will try that, thanks -NT - (boxley)
         The problem is with the if - (scoenye) - (3)
             saved once again by someone who is not a duffer, thank you - (boxley) - (2)
                 Welcome. You can scratch all the dirs from egrep - (scoenye) - (1)
                     I didnt want the files in those directories moved -NT - (boxley)

Let Us Now Braise Famous Men, those who in their salad days.. imagined that they were of the Caesar variety.
74 ms