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.
#!/usr/bin/perl -d
#use strict;
my $list = 0;
my $i = 1;
my $a = 0;
while (my $i < 10) {
"(perl -pe //zyphf.$i.com/)" >> list1;
cat $i;
}
my $c = 1;
open FH,list1;
while (my $c in list1 < 10) {
touch $c > dir1
}
close list1;
Since asking you for details didn't work, asking you to post code in CODE tags likely won't either..but please do so.
You *STILL* don't say what you're trying to accomplish...you have written a VERY small perl script to touch a file, and that perl script isn't too robust. Want to do a redirect? Here you go:
Code:
#!/usr/bin/perl -Tw
use CGI;
$query = new CGI;
print $query->redirect('http://website.url/');
There's a redirect for you. However, if all you're wanting to do is basic hosting...you do realize there are entire software suites dedicated to templating websites as they're built, right?? Including the blank pages, redirects, etc.
TBOne . I don’t know what I am trying to accomplish. I came up with an idea four or five days ago and posted my idea. I took until today for me to figure it out. I’ve always been like that running on intuition. Not smarts but a hunch. I guess my goal is to have a site with 1000 pages.
Actually it is not yet clear what your idea is. Can you please describe what your goal is at a high level --- without mentioning ANY specific method or technology? That would help a lot. Otherwise the posts just are confusing, at best.
TBOne . I don’t know what I am trying to accomplish. I came up with an idea four or five days ago and posted my idea. I took until today for me to figure it out. I’ve always been like that running on intuition. Not smarts but a hunch. I guess my goal is to have a site with 1000 pages.
TBOne . I don’t know what I am trying to accomplish.
Then what, exactly, do you think anyone is going to be able to tell you??
Quote:
I came up with an idea four or five days ago and posted my idea. I took until today for me to figure it out. I’ve always been like that running on intuition. Not smarts but a hunch. I guess my goal is to have a site with 1000 pages.
So you want to have a standard, generic web server. Unless you have ANY CLEAR IDEAS on what you need/want to do, there is zero anyone can do to help you. There is no 'intuition' or 'a hunch'; unless you have a goal, you've got nothing to work towards and consequentially, no idea WHAT you need to do.
Quote:
Originally Posted by dugan
I'm speechless...
Given this and the OP's other threads, I'm not surprised in any way.
I don’t know what I am trying to accomplish. I came up with an idea four or five days ago and posted my idea. I took until today for me to figure it out. I’ve always been like that running on intuition. Not smarts but a hunch. I guess my goal is to have a site with 1000 pages.
You're probably starting to realise it by now: you're seriously pissing off some people with your request - people who take your problem seriously and honestly try to help you. This is a slap in their faces, a complete dismissal of their efforts.
What you wrote there should have been part of your very first post.
Instead, it is post #21, after you have been asked in almost every post to specify your requirement.
Each time, you should have answered "I have NO requirement at all, I'm just doing it for fun" - and that would have been totally OK.
There is so much wrong with this behaviour, I can't even...
Please, don't ever do this again.
I can see you have an inquisitive mind in all things coding, which is good and valued here on LQ, but don't ever try to make others jump on your whim again.
The forum interface has a lot of buttons that will put markup tags into your post. One button puts [code] [/code] tags there, or you can type them manually instead. Then put your script, program, or data between the tags and it will be much easier to read as the spacing and indents will be preserved and a monospace typeface will be (depending on your browser) be used.
So if you have the following in your post,
[code]
#!/bin/sh
echo "Hello, World!"
exit 0
[/code]
Then it will look like this,
Code:
#!/bin/sh
echo "Hello, World!"
exit 0
and it will then be easier for people to work with.
Since asking you for details didn't work, asking you to post code in CODE tags likely won't either..but please do so.
What are code tags?
Seriously??? Out of all the questions asked of you, THIS is what you respond to?? Since you're so 'intuitive', it's odd that you've never looked at ANY of the buttons on the posting editor window at the top of what you're typing.
I was way off-. Here is what a Contractor provided for me after I gave him my code!
It’s in Bash. I’m dining on crow.
Code:
#!/bin/sh
PREF=$1
COUNT=$2
if [[ "$PREF" == "" ]]; then
echo "empty file prefix!"
exit 0
fi
if [[ "$COUNT" == "" ]]; then
echo "max count not specified!"
exit 0
fi
for i in $(seq 1 $COUNT)
do
echo "${PREF}.${i}.com"
touch "${PREF}.${i}.com"
done
exit 0
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.