Perl help: server1 writing to server2 behind firewall
Hi gang,
I've got two Linux web servers behind a Cisco firewall. Use Perl scripts to read/write from/to text files. Just had my ISP connect the two servers on a "private network".
Now I want a Perl script on server1, in addition to writing to a text file on server1, to also write to a backup text file on server2.
When I just had one server, I would use the following code:
open(BOB,">>/home/username/domainname/cgi-bin/logfile.txt");
flock(BOB, 2);
print BOB $newinfo;
flock(BOB, 8);
close(BOB);
Is writing to server2 as easy as putting server2's (private) IP address before the /home? probably not...
Or is that what the chapter on "sockets" is all about in my Perl Cookbook?
Any help, direction, links to more information would be much appreciated.
Thanks,--critical
Wil posted this at 14:49 — 8th May 2002.
They have: 601 posts
Joined: Nov 2001
There is no direct way to open a filehandle on a remote server; you would need to open a socket to the remote server, with a process at the other end of the socket cooperating in writing the file. (For example, HTTP works by having your browser open a socket to the remote machine and sending a request; then the web server on the remote machine cooperates by sending back the requested data.)
The easiest solution in this case is probably to create the configuration file locally, and then upload it to the remote server with Net::FTP.
- wil
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.