CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
How do I mirror 1 file to different directory

 



spaz
Novice

Sep 20, 2000, 10:01 PM

Post #1 of 7 (1467 views)
How do I mirror 1 file to different directory Can't Post

I've got a database in which I need to have the file in two places on the site. Once it gets updated in one place, I would like it to automatically mirror to the other directory. This doesn't seem that hard, although I'm having a hard time getting it to work. Any thoughts?


perlkid
stranger

Sep 21, 2000, 12:07 PM

Post #2 of 7 (1467 views)
Re: How do I mirror 1 file to different directory [In reply to] Can't Post

 
Try this,

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use File::Copy;
copy("/path/file.txt", "/new_path/file.txt");
</pre><HR></BLOCKQUOTE>

perlkid

P.S. That code came from a book called "Perl Core Language, Little Black Book", I highly recomend it.


spaz
Novice

Sep 21, 2000, 12:30 PM

Post #3 of 7 (1467 views)
Re: How do I mirror 1 file to different directory [In reply to] Can't Post

Thanks for the message. It still doesn't work. One of the files (the one I want to update) is located in the cgi-bin at /cgi-bin/data/file.txt. Do I need to set up different permissions in that directory.


perlkid
stranger

Sep 21, 2000, 1:52 PM

Post #4 of 7 (1467 views)
Re: How do I mirror 1 file to different directory [In reply to] Can't Post

 
It maybe so, I think you have to have directory permissions set to 777.

Try putting the script to update the file in the cgi-bin (The same place as the file your updating) so It can copy it localy, then have it copy the file to a different name like this,

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use File::Copy;
copy("file.txt", "file2.txt");
</pre><HR></BLOCKQUOTE>

I'll play with that code now though.

perlkid


perlkid
stranger

Sep 21, 2000, 2:16 PM

Post #5 of 7 (1467 views)
Re: How do I mirror 1 file to different directory [In reply to] Can't Post

 
ok,

I got it to work for me and here is what I did,

I have both directorys that my file exists in and that I'm copying it to chmoded to 773, And 777 will work but 773 is safer. Then I put my cgi file into the bin that the file is going to be backed up to. Then I used the same code in this way,

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use File::Copy;
copy("/path/to/cgi-bin/test.txt", "file.txt");
</pre><HR></BLOCKQUOTE>

Then in the directory where my cgi script resides is where the file called file.txt was created with the same content of test.txt.

So try that,

perlkid


spaz
Novice

Sep 22, 2000, 4:41 AM

Post #6 of 7 (1467 views)
Re: How do I mirror 1 file to different directory [In reply to] Can't Post

Thanks Perlkid! Works great...


perlkid
stranger

Sep 22, 2000, 7:49 PM

Post #7 of 7 (1467 views)
Re: How do I mirror 1 file to different directory [In reply to] Can't Post

 
I'm glad Smile

perlkid

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives