Perl or bash script to redirect traffic to another site.
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
It is in POSIX shell, of which Bash is a superset.
However, it is really close but is missing some essential changes to prevent it from providing backdoors to the system. If this is being served to the public over HTTP or HTTPS it would be very important to validate the input data to make sure it is what it needs to be and not something sneaky instead. As it stands, someone could feed $1 something malevolent to cause trouble with the touch or echo lines.
Quite true; but as of yet (two pages in), we *STILL* don't know what the OP actually wants to do, and they don't know either, according to post #20.
It is in POSIX shell, of which Bash is a superset.
It's using the non-POSIX new/extended test [[ so it wont work on systems where /bin/sh either links to Dash/etc or triggers POSIX-compliance mode (which I believe is the case with Bash).
But anyway, the OP is either a troll and/or a help vampire, so unless/until they're willing to put effort into asking their questions here appropriately, I don't think it's worth wasting effort trying to explain.
That code above is bunk. It’s like a big toe in the water. DUGAN has the right idea! It is GO. I don’t know GO so I am probably left out. But he wants to map anyone to many. You laugh but FACEBOOK does this and makes a ton of $. They access of millions of pages for free.
What the above script points to is a list of files and the creation of files. You have to then figure out the mapping. Maybe you can do this in peri. I haven’t done it yet.
That code above is bunk. It’s like a big toe in the water. DUGAN has the right idea! It is GO. I don’t know GO so I am probably left out. But he wants to map anyone to many. You laugh but FACEBOOK does this and makes a ton of $. They access of millions of pages for free.
What the above script points to is a list of files and the creation of files. You have to then figure out the mapping. Maybe you can do this in peri. I haven’t done it yet.
Sorry, no. You **STILL** have not defined what it is you're actually trying to do, and have gone back and forth from bash scripts, perl, go, etc., and as of yet don't know what you actually want to accomplish. And you obviously have zero idea of how relational databases work, or even the basics of how a site like Facebook operates behind the scenes.
You have no actual goal, which means you have no clear tasks to accomplish since you have no idea what it is you actually want to DO. And based on your posts, have VERY little knowledge of how any of this works, apparently. Do you even know what a redirect IS? The ways to accomplish it? WHY you want to? Do you know what a reverse proxy is? These are all things in this very thread. If you don't know any of this and have no clear goal, why are you bothering to post here???
I once remember OCLUG a linux user group. This was years ago. Someone who did linux for a living was stuck and couldn't solve a problem. They literally tried for a month till they got it right. Ill never forget that.
I once remember OCLUG a linux user group. This was years ago. Someone who did linux for a living was stuck and couldn't solve a problem. They literally tried for a month till they got it right. Ill never forget that.
This is not that situation, as TB0ne and others pointed out repeatedly.
perl
use LWP::Simple
my $res = get($url);
then search the url against a list of files.a match would display the file.
Too simple yes or no ?
No idea, because we **STILL DO NOT KNOW WHAT YOU ARE TRYING TO DO**. You've been given NUMEROUS things (and I even handed you a redirect in Perl) so far. You seem to have selective blindness when it comes to questions we're asking you, since you only seem to address what you feel like seeing.
Quote:
Originally Posted by Fred27377
I once remember OCLUG a linux user group. This was years ago. Someone who did linux for a living was stuck and couldn't solve a problem. They literally tried for a month till they got it right. Ill never forget that.
How inspirational. But the difference between that person and you, is that they could clearly articulate what they were trying to do, and they had a goal. You apparently have neither.
I want to start with a http request and map it to a page. One request to one page. But I am trying to avoid making and mapping these sites in advance. Their are seven sites on the box and I’m sure there could be 1000 more. But if possible I don’t want physically create the next 1000 sites. If they could be created on the fly it would be wonderful. The sites on the box now are Apache.
I don’t want physically create the next 1000 sites. If they could be created on the fly it would be wonderful. The sites on the box now are Apache.
Something or someone will have to create the sites, there's no magic. Either you create it or use a tool like Ansible or Puppet (or one of the many others) to create it.
Even then what condition would have to be met for the sites to be created, that will need to be programmed.
Let me begin again.
I want to start with a http request and map it to a page. One request to one page. But I am trying to avoid making and mapping these sites in advance. Their are seven sites on the box and I’m sure there could be 1000 more. But if possible I don’t want physically create the next 1000 sites. If they could be created on the fly it would be wonderful. The sites on the box now are Apache.
...and....
Quote:
Originally Posted by Fred27377
I sorry if it took me so long to get it out!
Seriously?? It took you THIS LONG, after being asked so many questions, to finally answer???
Go back to post #19 and re-read it. AGAIN there is already existing software to create web templates for different sites. Web hosts use it all the time. Look up cPanel, install it, and you're finished. Use the methods dc.901 told you...but at some point YOU, PERSONALLY, are going to have to do some actual work, and put some effort into whatever it is you're trying to accomplish...which we (and apparently you), don't know. And you don't 'map' a request to a page...a domain points to a website/url. That's not a 'redirect'...simple virtual hosting.
Again, you do not appear to have a clear goal, or even basic knowledge of what you're trying to do and accomplish.
Is it fair to say that you just don't want to pre-write static HTML files? That's typically solved with an application server. Apache (or Nginx) passes the HTTP request to an application that you write; you have the application generate the response, and it and passes the response to Apache to send back. You've heard of PHP and Ruby on Rails right? That's what they're for.
Personally, I recommend looking into Django, which is for writing these in Python. The official tutorial should give you a pretty good idea of how these typically work:
I want to start with a http request and map it to a page. One request to one page. But I am trying to avoid making and mapping these sites in advance. Their are seven sites on the box and I’m sure there could be 1000 more. But if possible I don’t want physically create the next 1000 sites. If they could be created on the fly it would be wonderful. The sites on the box now are Apache.
I think you need to start running a server and see how it works; once you do that you will understand that what you wrote there makes very little sense.
As the previous poster dugan, I think you just want to serve a lot of different pages.
Quote:
Originally Posted by TB0ne
No idea, because we **STILL DO NOT KNOW WHAT YOU ARE TRYING TO DO**.
They want to save the world from Covid-19 with "a box with a database of 320 million"!
320 million what, you might ask? As of right now, that is still shrouded in mystery.
ODOHO it seems to me that Covid can be tested by Saliva and a computerized record kept. We must be very close to putting this nightmare behind us. I called AWS to ask if they could setup something like this. They sent me an email. I don’t want to wait two years or more to begin to live again. 320 M is the approx people in US. Doing something for me is better than doing nothing at all!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.