recursive rcp

I wrote a shell script (AIX) to extract the file "/rep1/toto" from all the hosts referred in a list and send them to one local directory named ~/$host-$file with the hostname as prefix

rcp -p user@host:/rep1/$file ~/$host-$file

where file = toto ==> it works !

I would do the same thing but with "/rep1/toto*" (all files beginning with toto in /rep1 ) and naming these files "$host-$file"

for example : host1-toto1 ; host1-toto2 etc...

could someone help me , please

thanks in advance

christian

for i in `rsh $server "ls /rep1/"`
do
rcp /rep1/${i} mycomefromserver:/path/to-dir/${server}-${i}
done

Regs David

Thanks for your answer , but first i would test if i enter :

/rep1/toto or

/rep1/toto* , in other words if the input contains a "*"

to do or not the loop

i'm searching for the test , if you have the answer please welcome !

christian

Try

case $INPUT in 
    *\*) echo input ends with a star;; 
    *) echo otherwise;; 
esac

Thanks that's right ,

last thing , for the same script i would extract the filename from a string whether the string is short or long :

/rep1/rep2/rep3/file => file

or /rep1/file => file

i'm trying with awk command and NR parameter without success at this time , maybe (for sure) you will find before me ?

thanks

christian

For sure, lookup the dirname and basename commands

basename /rep1/rep2/rep3/file

in french , we say "bon dieu mais c'est bien s�r"

=> oh god for sure

sorry i'm surely tired , it was so simple !

thanks a lot

christian