Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux noob question on scripts 2

Status
Not open for further replies.

Hondy

Technical User
Mar 3, 2003
864
GB
Hi

I'm new to Linux and I'm looking for some help on Shell Scripts. I am trying to fix a legacy web application which has involved reinstalling Apache which is fine.

My problem is that the old system used .sh scripts, I see there is a "sh" executable in a CGI-BIN directory.

1) what application is this?
2) how do I install it on my new Apache server?

Thanks

Hondy
 
OK so it seems that SH is Linux's built in script engine.

The scripts that I need to run via a web page on apache all have #!/bin/sh at the start, should these run easily through a web link? The only reason I ask is that they are sitting in a CGI-BIN directory, they don't need to be right?
 
The .sh extension indicates that it's a Bourne-shell script.
So to answer your questions:
1) It's a regular shell script.
2) There is no spesial way to "install" a shell script.
Basicaly you just copy the .sh file to the desired location,
and make sure it's executable.
A command like:
Code:
chmod +x scriptname.sh
would make the script named scriptname.sh executable.

Some usefull links about Linux and scripting:

And a good book:
:)
 
Thanks, that confirms what I thought, I have no idea why they are in a CGI-BIN directory, must be an historical thing.

Cheers
 
What geirendre was saying applies to from the command line.

cgi-bin is a security thing. The idea is that all exeutable scripts (that aren't modules to the apache (like PHP)) should be in cgi-bin and then the web root should never have anything in it that has the executable flag set.

They need to be in cgi-bin to be executed as a cgi script. So that whoever is the admin for the server can quickly check what can and can't be executed.

If the urls bother you, you can use mod_rewrite rules to make the URLs look like the scripts are in more relevent places. See:
[plug=shameless]
[/plug]
 
thanks jstreich, that makes sense, so its more of a best practise than a functional thing. I always thought that CGI-BIN was a perl only affair.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top