Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, i have a server that has hundreds of domains that are use for email, the actual sites are just used to point users to main site and act as search engine boosters.
Obviously i do not want to changed each file one by one, and though i am new to linux i know that i can create a shell script to copy the new index.html to all the individual /home/domain/public_html/ directories.
Can any one help me out with how best to acheive this?
eithir i am slow to undestand or you do not understand what i want to do.
The syntax given seems to be to copy new index.html to one domain at a time or all domains at same time.
I want to automatically copy new index.html file to a list of selected domains, not all my domains.
This why i asked how to incluede list of domains 'user name' dir
In below how would i insert a list of domain user dir, where
{list} is where the list would go.
what you said, "cp index.html /home/${domain1 domain2 domain3 domain4 domain5 }/public_html"
is completely wrong (no offense!), bash can't do that, and specifying a program to run like that would not work, as you'd be using 'cd' not your own script by the way you wrote that, you have been given pretty much the same solutio tweice now, whcih does exactly what you are after. what else do you require that their solutions don't provide?
personally i'd use a shift call to move the script parameters along, and call $2 continuously in a for loop, but there's loads of ways of doing the same thing.
you seem to be being somewhat dogged in this illegal syntax you seem to be after. I'd suggest reading up on shell scripting. look at some of the books on the link on my signature
nah, you see now that's a general jumble of al the different solutions... you really need to read up on shell scripting. the way i've done it here is a little more subtle i think than most other solutions, and is more flexible. i'll let you fine out exactly what shift and $* actaully mean.. but this DOES work...
[chris@trevor chris]$ cat script
filename=$1
shift
for dirname in $*
do
echo cp $filename /home/$dirname/public_html
done
[chris@trevor chris]$ ./script a b c d e
cp a /home/b/public_html
cp a /home/c/public_html
cp a /home/d/public_html
cp a /home/e/public_html
yeah? obviously, just remove the word 'echo' and it'll go copy the stuff, rather than just pritning out the command like i've done there.
and why do you want to call it blah.txt? it's not a text file, it's a script file. generally you wouldn't ever give script files a suffix at all.
Last edited by acid_kewpie; 02-07-2002 at 06:44 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.