|
CGI
Q: Where is my
cgi-bin?
A: /yourdomain-www/cgi-bin/
PATHS
Q: What is my path to
perl?
A: /usr/bin/perl
(first line should read exactly #!/usr/bin/perl )
Complete vs Relative URL and Path
Q: Can you give me an example of a complete relative URL and a complete
path?
A:
1. Complete URL: http://www.domain.com/file.htm
2. Relative URL: /cgi-bin/myprogram.cgi (that would mean that it
needs to look for a cgi-bin folder off of the same folder that the
index.html file is in)
3. Complete path: /home/username/domain-www/filename.html
4. Relative path: /filename.html That will look in the same folder you
are in for that filename. If you do ../folder/filename.html then it will
go up a folder first before looking for that new folder and filename.
What is the URL and Path of my domain?
A: The URL that corresponds with your cgi-bin directory is this:
http://mydomain.com/cgi-bin
And the PATH is this:
/home/username/mydomain-www/cgi-bin
Can you explain what a path is?
Especially when your working with cgi, you will have to know a path.
/home/yourusername/yourdomainname-www/directoryname/filename
the path is how the SERVER reads files. or we could do it
like your windows machine..
you have a C Drive and in your C drive you have folders (directories) so
if you were to manually type out how to get to your netscape you would
be typing..
C:\programfiles\netscape\communicator\netscape.exe <--- this is a
windows path.
/home <--- is like the C Drive
/your username <--- says what folder the files are all under
/yourdomainname <--- is like the subfolder everything else sits in
/cgi-bin <--- Special directory for certain types of programs.
/directoryname is your file your looking for.
this is a unix/linux path
SENDMAIL
Q: What is the sendmail path?
A: /usr/sbin/sendmail
Do I need the -t at the end of
sendmail?
A: Yes, that's part of the script, use: /usr/sbin/sendmail -t if that is
what the script is asking for :).
Q: Which version of Perl do you have installed?
A: We use Perl version 5.x with all of the standard CPAN modules
installed.
Using sendmail vs SMTP
Q: I am trying to put up a postcard cgi script. It isn't working and I
think the problem may be in the sendmail coding. They give you a choice
between SMTP_server or Send_mail and I am trying to use sendmail. Is
this right? Do I have to somehow use my AOL account instead? What works
with this server?
A: You are correct, the sendmail is what you want to be using (not the
SMTP), and it doesn't need to access your aol account to do so. That is
with the exception of having your aol address if it sends you an e-mail
for anything, but that's it.
The sendmail path you'll want to use is "/usr/sbin/sendmail". Some scripts
use an optional "-t" switch at the end of the path. If the script has the
"-t" switch by default, but the path to sendmail is different, be sure to
keep the "-t" switch at the end of the path like this "/usr/sbin/sendmail -t".
ERRORS
CGI Trouble Shooting:
- Make sure that your CGI scripts were uploaded in ASCII
mode when you uploaded them. If a script is uploaded
in BINARY mode, it will corrupt it and it will not work
- Do your scripts have the correct permissions? Most
scripts (the files ending in .pl or .cgi) need to have a
permission of 755 or rwxr-xr-x
You can change permissions in your File Manager if you like,
by clicking on the link out beside the file name that looks
like this: rwxrwxrwx and choosing
Owner: rwx
Group: r x
World: r x
That is what makes your script so that it will run
- Make sure that where it asks for a "Path", you
are not putting the URL A path will never have the
"http://" in it. A path looks like this:
/domain-www/cgi-bin or possibly /home/username/domain-www/cgi-bin/script.pl
if the first one doesn't work.
- Be very careful when editing a script.
Generally, it is best to just leave it alone unless you have
scripting experience :) But if you do change it, proof-read
all of your periods, commands and quotes. The script won't
work, unless everything is there. :). I highly recommend
making yourself a back-up copy of your script before you
start changing anything.
Q: I am trying to get cgi to work on my website according to the help files. I need a directory call
usr/bin/perl
A: All cgi files use that directory, and it's already there on your server. You just can't see it because nothing in it will ever need added or changed by you. You only need to use that name on the script where it mentions, you do not need that script in that directory. What you'll want is the cgi program in your
cgi-bin directory, then at the top of each .cgi webpage you'll want to replace something that looks almost exactly like the
following line with "#!/usr/bin/perl".
How can I correct an Internal Server
Error?
The Internal Server error can be the result of a few different things.
Below is a list of what it usually is.
1. Your program can't find one of the associated programs called from
the one file.
2. Upload all .cgi or .pl files in ASCII mode only (not Binary, and you
can't use Auto mode either)
3. Make sure they have the correct permissions. Most cgi scripts require
the 755 (or rwxr-xr-x) setting, and files it writes to (.txt files)
usually are set at 777 (rwxrwxrwx).
4. Make sure the path to perl is /usr/bin/perl (read exactly "#!/usr/bin/perl")
and the path to sendmail is /usr/sbin/sendmail
5. Check to be sure that you have your URL's and your path's set
correctly.
TUTORIAL
CGI Tutorial:
http://www.cgi101.com/class
Q: Where can I learn more about
Perl?
A: http://www.perl.com
CUSTOM SCRIPT
Do you know where I can get a custom
script?
http://www.trxx.co.uk/ .
http://www.gossamer-threads.com
.
http://www.waytotheweb.com/webscripts/index.htm
http://www.cgi-resources.com
may have one that is already done :).
Q: Where can I get more Perl
and/or CGI scripts?
http://www.cgi-resources.com/Programs_and_Scripts
http://www.scriptsearch.com
http://www.cgi.elitehost.com
OTHER
INFORMATION
Can I put a
cgi-bin folder in a
secondary folder?
Normally cgi-bin is just one folder that you put all your cgi scripts in
and it is never in a secondary folder. I don't know if that causes a
problem or not unless you ever have to use a script with a .pl ending
because then it wouldn't work unless it was in
/domainname-www/cgi-bin/ because it has to be "script aliased"
to work and that is where the script alias on the system points.
Can I write my own scripts to use on my
web page? if so what are the access procedures for cgi-bin?
Yes you can write your own cgi scripts, but that requires the knowledge
of a programming language such as PERL, C+, or similar language. An
easier method is to take pre-written cgi programs to use to fit your
needs. The best resource for them that I use is here: http://www.cgi-resources.com
I can't see my .txt file.
Q: The http://www.mydomainname.com/cgi-bin/readme.txt doesn't come up.
A: ".txt" files aren't usually accessible via your browser in
the cgi-bin directory, but the .pl file is.
Where is the
\cgi-sys\ sub-directory in
my folder?
Q: I am trying to configure a form using your formmail.pl. Where is the
\cgi-sys\ sub-directory in my folder?
A: There actually is a cgi-sys directory of your website, it's just
invisible to the file manager and ftp programs because the files within
it can not be changed.
How do I upload a cgi file?
To upload cgi files you just upload like you usually do, but make sure
you upload in the directory entitled "cgi-bin". Also when
doing so please make sure you're uploading in "ASCII" mode
only (not Binary).
PERMISSIONS
Please explain what the chmod command
means.
The first number of a 'chmod' command applies to the 'owner' of a file.
(ie you via ftp or telnet)
The second number applies to the 'group' that the file belongs to.
(ie your account)
The third number applies to 'other'.
(ie everyone else)
And,
Read=4
Write=2
Execute=1
Therefore when you set a chmod of 755, you are saying:
The owner (you) can read, write, and execute the file. (4+2+1=7)
The group (your account) can read and execute the file. (4+1=5)
Other (everyone else) can read and execute the file. (4+1=5)
Note that 'read' does not mean that visitors to your website can 'read'
your script...they can't. It just means they can use it.
Also note that 'write' does not mean your visitors can write to your
files. It just means that when they access your script, the script
itself is allowed to write to a text file.
How do I set permissions in my file
manager?
To set permissions on files and directories all you need to do is to go
to your file manager, find the file you're looking for, and click on the
link next to it that looks like "rw-r--r--" in the column
entitled "Permissions". Once you click on that you can modify
the permissions. "rwxr-xr-x" is the same as 755 (which is the
general executable permission setting), and "rwxrwxrwx" is
777.
What are the CHMOD #'s vs. letters?
Q: I need to change the CHMOD but the file manager doesn't show the # -
can you tell me how they correspond with the letters?
A: CHMOD
777
rwx rwx rwx
644
rw- r-- r
755
rwx r-x r-x
707
rwx --- rwx
666
rw- rw- rw-
|