philbe has asked for the wisdom of the Perl Monks concerning the following question:
Actually I own two different web servers(accounts). I have in Server 1 a Perl cgi that creates web pages: Directories, Html files, upload files, deletes... everything done in the same server.
My question is: Is possible to keep the perl script in Server 1 and create all the web stuff in Server 2 ?.
Can you give me a little advice ?. Thanks in advance.
Re: perl script accesing another server
by Wookie (Beadle) on Jul 26, 2001 at 14:19 UTC
|
You could also try ftping the files from server1 to server2, having created them on server1.
A quick Net::FTP script should do the job nicely :).
Try http://www.perldoc.com/perl5.6/lib/Net/FTP.html if you're unfamiliar with the module :).
game(Wookie,opponent) eq 'Wookie' ? undef $problem : remove_limbs(arms,opponent); | [reply] |
Re: perl script accesing another server
by wine (Scribe) on Jul 26, 2001 at 14:24 UTC
|
You could create a simple ftp-script. It should remove the current content of server 2 and copies all the new content from server 1 to server 2.
You can choose to call this program from inside your cgi-app or through a schedular, depending on when you want your update to be done.
Update There is another quick solution along the lines of:
[user@server1]$ tar -czvf - web/ | ssh user@server2 'rm -rf web/ ; tar
+ -xzvf -'
From man ssh to login without a password::
ssh implements the RSA authentication protocol automatically. The user
creates his/her RSA key pair by running ssh-keygen(1). This stores the
private key in $HOME/.ssh/identity and the public key in
$HOME/.ssh/identity.pub in the user's home directory. The user should
then copy the identity.pub to $HOME/.ssh/authorized_keys in his/her ho
+me
directory on the remote machine (the authorized_keys file corresponds
+to
the conventional $HOME/.rhosts file, and has one key per line, though
+the
lines can be very long). After this, the user can log in without givin
+g
the password. RSA authentication is much more secure than rhosts authe
+n
tication.
This has a few advantages:
- It's secure
- You don't have to supply your password
- You use less bandwidth
- You can execute other commands at will on server 2
| [reply] [d/l] [select] |
|
An even quicker solution is to use
rsync over ssh. It offers all of
the same advantages except that it also offers the
following:
- Substantially faster.
- Fewer places to make bad assumptions.
- Not as dependent upon a persistent network connection.
- You can handle deletes as well.
| [reply] |
Re: perl script accesing another server
by RatArsed (Monk) on Jul 26, 2001 at 14:07 UTC
|
Yes and no.
If both accounts were sharing the same physical storage, then it's merely a permissons issue
In the worst case, when both servers are on opposite sides of the world running completely different OSes, then you'd have to either write a WebDAV client and server, if you don't already have a WebDAV enabled server.
--
RatArsed | [reply] |
|
Is not the worst... but near.
They are in different locations but running the same OSes: Unix, Apache.
The main idea is to offer some people the service to create web pages using my script in my "Server 1" but allowing them to own is domain: www.hisdomain.com with his own server...and the generated web pages, and not (like now) www.mydomain.com/somepeople.
Anyway I thank you very much. I will investigate WebDAV.
| [reply] |
Re: perl script accesing another server
by wardk (Deacon) on Jul 26, 2001 at 20:08 UTC
|
If I understand the issue correctly, you have info on server 1
that you really just want accessed/displayed on server2
I've done this sort of thing numerous times to get data
from locked systems to an "enternal" source. i.e. getting oracle
billing data to a customer without letting them actually touch
a box that is directly connected to the network oracle is on.
Another project I am working right now, allows an external division
across the world invoke our CGI input screen without actually using them
directly....i.e. they use their existing interface, which calls my system passing
what would have been entered into our forms. they then have to parse some specially
formatted output that indicates the status of their requests, but we have made that
fairly easy by creating consistent markers they can use to snag the real data...the
biggest hurdle we face is that the system calling us is ASP based, getting them to
figure out how to do what LWP does via ASP, and parsing without the benefit of a regex.
If this is the case, simply create all the web pages on the
source server1, then use a front end on the access server2 call
server1, redisplaying the data on server2.
LWP can make this fairly easy. And it's damn fun.
of course, if I misunderstand the problem....nevermind :-)
| [reply] |
|
Dear Wardk (and the other people helping):
I think the main problem is that I'm a novice in Perl, no matter if my script works and is 10,080 lines long (390 K).
Your solution sounds good but I need to learn a lot about LWP.
Just in case you have nothing better to do (!!!), I will tray to explain "the thing" (and sorry for my english):
I have a domain (lets say "www.philbe.com")hosted in a Verio server and there is where my script resides.
Filling some forms the users can create a set of 5 web pages that can be created and edited at anytime by themselves without knowing nothing about HTML.
Here is a piece of the script:
#!/usr/local/bin/perl
...............................
...............................
# Form : for user input to crate the Headline:
<b>Top Of Page:</b>\n";
print "<p><b>Headline:</b>Big Page Title At The Top - required)<br>\n"
+;
print "<input type=text size=40 name=\"headline\" value=\"$head\"></p>
+\n";
...............................
...............................
# writes te input into a flat file
...............................
...............................
#Creates Dir and Page sub dirs
mkdir ("$base_dir/$pagename", 0777) || die("Could not create user dire
+ctory:");
mkdir ("$base_dir/$pagename/page1", 0777) || die("Could not create use
+r directory:");
..............................
..............................
#Page 1 creation
open(HTML, ">$page_dir$pagename/index.htm") || die "I can't create $pa
+gename/index.htm\n";
if ($useflock) {
flock (HTML, 2) or die "can't lock html file\n";
}
print HTML "<html><head><title>$head</title>\n";
................................
................................
................................
The problem is that this pages are created an accesed under: www.philbe.com/anyusername
and some of them prefers, (due to commercial reasons), to have: www.anyusername.com
So is mandatory to get his own server (and domain, of course).
The easy solution is to install a copy of the script in is server...but... I don't want to let the users put his hands on the script code.
So the other, looks like no easy, solution, is to have a "central script" in my server creating (or copying) the pages in his own servers. No matter if I need to keep a personalized copy of the script for each one.
One of the interesting features of this sort of scripts is that the users can see the changes done on the web pages, and on the Net,(think in new "Prices", "Offers of the day" ...)in the next five seconds after the "Editions" (or the first "Creation").
May be the answer to this problem, is this phrase:
"Dear Philbe, learn a "little bit" more of Perl".
Anyway thank you very much. !!!
| [reply] [d/l] |
|
|