Help - Search - Members - Calendar
Full Version: Copy file to multiple domains?
The Planet Forums > System Administration > Backups, Restores and Transfers
dewpoint
I am trying to take a file from my server's root directory and copy it to the cgi-bin in all of my domains. (Note, this is on a pleske box).

For the life of me, I can't remember how to do this.

This is what I tried using:
cp t_links.words /home/httpd/vhosts/*/cgi-bin/

The first domain works fine but then I get the following error for the rest of the domains:

cp: omitting directory `/home/httpd/vhosts/mydomain.com/cgi-bin/

Any suggestions?

Thanks,
Brian
mmyers
Hi Brian,

If you are using bash, you will need to use something like a for loop in order for that to work properly because of the way the wildcard expands.

For instance, you might try something like the following:

CODE
for i in /home/httpd/vhosts/*;
do
     cp -v t_links.words $i/cgi-bin/;
done;


In this case, the * in the for loop expands to the name of the directory and is saved into the $i variable. Since this is a for loop, it will iterate the command after 'do' for every directory it finds.

The reason you can't simply use the cp command is because the * will expand before the command is executed, resulting in the command only working for one directory.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.