The readme.txt file told me to download the cgi scripts to this path: #!/usr/bin/perl
Now, this is my first question. I can get all the way to: #!/usr/bin, but then "perl" is NOT a folder, but a file. Does this mean I need to right click on that "perl" file and upload my CGI scripts that way, or can I just upload them into the "bin" folder?
What I did was upload my cgi scripts to the bin folder...which is where I think the problem is coming in.
Anyway, it could be how I've scripted the code right on my page? Here's a sample of the code I have on my web page:
<!-- Start of code:
<a href="http://www.advertiser-site.com/#!/usr/local/bin/clickmanager.cgi?dl=http://www.mydomain.com">AnchorText</a>
<!-- This is where classified text goes --><br>
[Hits: <!-- #include virtual="/#!/usr/local/bin/clickmanager.cgi?num=http://www.advertiser-site.com/" -->]
End of Code -->
The "Hits" part above is where I want the number to increment everytime my advertiser's site is clicked on. Can any of you see where I'm flawed in this script...Or perhaps the path where I've uploaded my CGI scripts? Thank-you so much for your time! I hope that someone knows enough about scripts that they can help me! Thanks :)
Dave.
I think you may have misread those instructions:
> The readme.txt file told me to download the cgi scripts to this path: #!/usr/bin/perl
That text, "#!/usr/bin/perl" is the "standard" opening line of any PERL script, and tells the scripting parser where to find the PERL interpreter. If for some reason you had a non-standard setup, you would have to change that to point to the PERL interpreter's actual location, for example, "#!/usr/local/bin/perl".
So, you should be able to install your downloaded scripts wherever you want to, provided that the links from your html pages and the references from one script in the package to another are all correct and consistent.
That's really all I can contribute, I'm afraid.
HTH,
Jim
If you are unsure you can run "whereis perl" from a shell if you have shell access.
Generaly cgi-scripts can be placed anywhere in your server so long as you referance the locations correctly. Usualy you create a folder to hold the script, or one to hold all your cgi scripts for example cgi-bin.
Hope this is of some help.
Mack.
Like jdMorgan said your path to perl could be #!/usr/bin/perl or #!/usr/local/bin/perl, you will get is a server error if it's the wrong one. Don't forget to chmod the script to 755 or it won't work and you will get another server error
No, you only change that "#!/usr/bin/perl" line if the PERL interpreter for your hosting account is installed in a different location from what that line specifies. Contact your host if you don't know where it is.
You can upload your scripts to any location you like, as long as your pages link to them at that location, and as long as any links the scripts have to each other specify that location.
Your html pages call (link to) the scripts. The scripts "call" the PERL interpreter at /usr/bin/perl, or whatever location is specified in the first line of the scripts. And the scripts may call each other, too (using directives like #include or require). You may have to read through the scripts to find out, if the documentation is unclear or muddled.
HTH,
Jim
- Your webpage tells the visitor's browser which page to ask for. So in your webpage, the cgi script should look like a web url (except with .cgi or .pl at the end instead of .html (e.g. [domain.com...]
- If the page requested is a cgi script, then your webserver (e.g. Apache) knows that by a combination of things, but the subdirectory is the main one.
- The webserver then runs the cgi, gets the result, and passes that back to your browser as an html file. To know how to run the cgi, your webserver uses the hash-bang line (among other things)
So....
"...Generaly cgi-scripts can be placed anywhere ..."
I'd suggest you put the script in your cgi directory. Your host should tell you what that is, but it should be something like cgi-bin under your main webpages directory (so, for example, the url to it would be [mydomain.com...]
)
I guess it is true that the script "can be placed anywhere in your server so long as you referance the locations correctly", but you would also have to tell the webserver (e.g. in Apache's htconfig) if you changed the location of the cgi files.
The hash-bang line should stay as #!/usr/bin/perl unless your host has perl installed to a different location, as others have written.
ncw164x wrote that "...some where on the script you should see path and this is where you put the full server path to the script...". I'd change the 'should' to 'may'. It may be true, but a well written script should not require that, so that may not be required.
Shawn
It's only after I posted I noticed that comment, I run over 60 scripts from my site, some have the path on the script and others reference a config file where all the details are placed
I also have scripts where you just reference it via http:// mydomain dot com/cgi-bin/nameofscript.cgi
It all depends on as you say how the script is wrote
It looks like you've got your paths confused.
Basically you have two kinds of paths:
one type is relative to the file system on the server
one type is relative to the document root for the web server
The #!/usr/bin/perl tells the script where to find Perl to do it's work.
Your links for using the script, the html part has
<a href="http://www.advertiser-site.com/#!/usr/local/bin/clickmanager.cgi?dl=http://www.mydomain.com">AnchorText</a>
when this path should be relative to document root on the web server, or something like this:
http:*//www.advertiser-site.com/cgi-bin/clickmanager.cgi
So you'll want to upload the script to your cgi-bin folder, and you should be good to go.
Hope this helps.
LisaB
[edited by: bunltd at 10:08 pm (utc) on July 20, 2003]
<!-- Start of code: <a href="http://www.advertiser-site.com/bin/clickmanager.cgi?dl=http://www.mydomain.com">AnchorText</a>
<!-- This is where classified text goes --><br>
[Hits: <!-- #include virtual="/bin/clickmanager.cgi?num=http://www.advertiser-site.com/" -->]
End of Code -->
Upload the "clickmanager.cgi" file into the "bin" folder, or "cgi-bin" if it's called that.
That's my take on it anyway
You *do* have to change that include link in your first post to
[Hits: <!-- #include virtual="/usr/local/bin/clickmanager.cgi?num=http://www.advertiser-site.com/" -->]
I think the problem is simply one of terminology and unfamiliarity. The process of how your pages call the script and where you can put your scripts has been pretty well defined above, I think.
I suggest you try this on a "test" html page, and experiment with it till it works, then put the links/includes on your public page(s) after testing.
Jim
Dave.
Oh my goodness, I think I'm even MORE lost now
You *do* have to change that include link in your first post to
[Hits: <!-- #include virtual="/usr/local/bin/clickmanager.cgi?num=http://www.advertiser-site.com/" -->]
assuming that you have put your counter script in your [yourdomain.com...] subdirectory
Well, it is possible to configure a webserver to have its cgi-bin directory be called "usr", but it would be a very unusual non-standard configuration. What is relevant is not just that you "...put your counter script in your [yourdomain.com...] subdirectory...", but also that your webserver knows to treat files in that subdirectory as cgi. So it would be better to put the file in the cgi-dir or cgi-bin or whatever is set up on your site for cgi, as TheWhippinpost suggested.
Shawn
Thanks for your help! I changed everything to exactly the way you said I should...still does not work :( When I type in "http://www.mydomain.com/cgi-bin/clickmanager/stats.cgi" into a browser I get a 404 error message! Yet, that is the EXACT location that I uploaded my cgi files to. I've even Chmod them to the right "permission" numbers too. I'm a little stumped I guess :(
Dave.
Shawn
have you double checked the path to perl for your server? While it's true that #!/usr/bin/perl is a valid path to perl I've seen some hosts that have it in a different place.
Also - you are using a server side include call to run the script - is your server set up to handle SSI? Does your test page have .shtml as the page extension? Most servers aren't set to handle SSI on just any page - it usually has to be .shtml. There are other ways to do it but for now lets just make sure you're using .shtml.
<edited for unbelievably bad grammer ;)>
In dealing with these things, a lot of accuracy is needed. These two paths are not the same:
If you have uploaded the script to a location as in (2) with the name "clickmanager.cgi", you will of course get a 404 (document not found) when trying the first address (#1).
/claus
<edit>
A 404 is easy: It simply means that the server cannot find the file. Servers are normally not wrong about this (although they can be convinced to make mistakes on purpose, but that's something else). I see you say it is the exact location. But you have two files, right? a html file and a cgi file? The html file must have a name ending in "shtml", not "htm", "html", or "cgi".
The html file calls the script, and the html file assumes that the script is stored at location (#2) - that's the location the others have suggested to you, so i guess that's what you have written in it. Try either changing the address to the script in the html-file or storing the script at location (#2) and _then_ entering the address of the html file into your browser (as saved with an "shtml" extension).
Hope this makes some sense to you, it's really not that difficult, it's just that a lot of things can be done in a lot of different ways.
</edit>
I have another query. I have created a cgi-bin folder in my ftp program. Now, I uploaded all the appropriate cgi,txt and pm files to a clickmanager folder. Thus, my path to that would be: /cgi-bin/clickmanager/ right? So, why is it when I type: [mydomain.com...] into my browser my server says it does not exist? And yes, it is the correct path I've typed into my browser...that has really perplexed me.
Dave.
One more thing though. For some reason, even though on my stats.cgi page it shows me how many hits a certain URL is getting, it isn't actually incrementing on my html page? I'm using the "include" command and it looks like this:
"<!--#include virtual="/cgi-bin/clickmanager.cgi?num=http://www.url.com" -->
So that each time www.url.com is clicked on I want a physical increment to be seen on my page beside this URL so that other visitors can see it. Any suggestions? Thanks again!
Dave.
The HTML-thing:
Try changing the file-name from "file.html" to "file.shtml" - this sounds crazy, but it has some importance in some cases.
Both things (settings for paths and file-extensions) can be changed. It seems like you have something like root access, so you might have the necessary priviledges to do it. On the other hand, if we can get it to work for you as it is now there's no need to change it ;)
/claus
"...On the other hand, if we can get it to work for you as it is now there's no need to change it..."
Just to add... It is very important that you don't change it. Claus is correct that this is quite ordinary. In previous posts I tried to explain that your webserver needs to know where the pages (html and cgi) that you are serving are referenced from. This is important for security. You are giving your visitors access to pages under that "html root" directory. You definitely don't wan't that to be your root directory so your visitors can get to anything in your e.g. usr directory. You only want to allow your visitors access to cgi scripts in your cgi-bin directory. Does that make sense?
Shawn
I was actually thinking about security the other day. Being new to this I'm totally exposed due to ignorance! So, what is it I should NOT change? Is it ok to change my file extensions to .shtml on pages I'm trying to use SSI? What exactly would allow my visitors access to my usr folder? Again, thank you all for your great help! This is what makes WW so awesome :)
Dave.
Security risks.. I do not believe ShawnR was referring to changing the file-extensions of specific html-pages here. This is not a risk.
I think he wanted to draw your attention to the fact that it is very important to know exactly which folders and files you want to make accesible by the public and which you want to keep private. With your structure this implies that stuff in, say,
usr/local/apache/
...is probably okay, as that is your domain root. On the other hand, a random web user should not be allowed to access other folders on the same level as "apache" or higher. Perhaps there's even some stuff in /apache/ or below that should be restricted, this all depends on your setup.
It's a little difficult to give general advice on these topics, as server setups are rarely 100% similar. On the other hand, please don't post any more details to the public (this forum can be read by anyone), consult someone you know personally or professionally in stead.
/claus
<!--#include virtual="/cgi-bin/clickmanager.cgi?num=http://www.urltocount.com" -->
*Do I need the "<!--" at the beginning and end for this to work? Or is this what is causing the problem in the first place?
Should I use this alternate line of code instead? :
<!--#include virtual="/cgi-bin/clickmanager.cgi?numall=1" -->
Thanks for your help :)
Dave.