PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Running external programs via cgi script
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Running external programs via cgi script

Réponse
 
LinkBack Outils de la discussion
Vieux 18/03/2008, 09h02   #1
newbiegalore
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Running external programs via cgi script

Hello all :-),
I am fairly new to writing CGI code using shell scripts. I have put
up a site which takes an input via a form and checks a pgsql db for
the matching entry and returns the associated fields for that. I want
that if that entry is not found in the db I should be able to populate
the db in real-time by running another shell script.

I added the second program in the cgi-bin folder (sec.sh) and then
tried to run it from my main cgi script. It seems that this program
just does not run. The code works OK as I have tested on my local
machine, I have set the permissions to 755, changed extension to .cgi
as well and have tried to get it to work. Even if sec.sh has just echo
"hello" > $wd/output , I can see the output file but there is nothing
in it!!!

Am I missing something crucial regarding what can be executed in the
cgi-bin directory? Any advice would be very ful.

Thanks,
-A

Extra information: Hosting agency: Hostmonster.com
the sec.sh will ideally contain a wget command and some awk. Awk and
wget are installed on the linux system of the hosting provider.
  Réponse avec citation
Vieux 18/03/2008, 10h32   #2
Michael Vilain
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running external programs via cgi script

In article
<8efc5501-7f65-48bb-abfb-ed38e738aae0@e10g2000prf.googlegroups.com>,
newbiegalore <banerjee.anirban@gmail.com> wrote:

> Hello all :-),
> I am fairly new to writing CGI code using shell scripts. I have put
> up a site which takes an input via a form and checks a pgsql db for
> the matching entry and returns the associated fields for that. I want
> that if that entry is not found in the db I should be able to populate
> the db in real-time by running another shell script.
>
> I added the second program in the cgi-bin folder (sec.sh) and then
> tried to run it from my main cgi script. It seems that this program
> just does not run. The code works OK as I have tested on my local
> machine, I have set the permissions to 755, changed extension to .cgi
> as well and have tried to get it to work. Even if sec.sh has just echo
> "hello" > $wd/output , I can see the output file but there is nothing
> in it!!!
>
> Am I missing something crucial regarding what can be executed in the
> cgi-bin directory? Any advice would be very ful.
>
> Thanks,
> -A
>
> Extra information: Hosting agency: Hostmonster.com
> the sec.sh will ideally contain a wget command and some awk. Awk and
> wget are installed on the linux system of the hosting provider.


You're using the Borne shell to try and populate a database? Well, I'm
sure it can be done, but you might check on other tools like maybe perl
to do this task. There's even CPAN modules you can install do do CGI
and database access directly from perl. And string manipulation is
built-in.

It's like you asked how to do a database program in FORTRAN IV. Sure,
it can be done, but it's way easier to do it in other, more modern
languages.

Why did you choose the shell?

--
DeeDee, don't press that button! DeeDee! NO! Dee...



  Réponse avec citation
Vieux 18/03/2008, 19h05   #3
newbiegalore
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running external programs via cgi script

On Mar 18, 2:32 am, Michael Vilain <vil...@NOspamcop.net> wrote:
> In article
> <8efc5501-7f65-48bb-abfb-ed38e738a...@e10g2000prf.googlegroups.com>,
>
>
>
> newbiegalore <banerjee.anir...@gmail.com> wrote:
> > Hello all :-),
> > I am fairly new to writing CGI code using shell scripts. I have put
> > up a site which takes an input via a form and checks a pgsql db for
> > the matching entry and returns the associated fields for that. I want
> > that if that entry is not found in the db I should be able to populate
> > the db in real-time by running another shell script.

>
> > I added the second program in the cgi-bin folder (sec.sh) and then
> > tried to run it from my main cgi script. It seems that this program
> > just does not run. The code works OK as I have tested on my local
> > machine, I have set the permissions to 755, changed extension to .cgi
> > as well and have tried to get it to work. Even if sec.sh has just echo
> > "hello" > $wd/output , I can see the output file but there is nothing
> > in it!!!

>
> > Am I missing something crucial regarding what can be executed in the
> > cgi-bin directory? Any advice would be very ful.

>
> > Thanks,
> > -A

>
> > Extra information: Hosting agency: Hostmonster.com
> > the sec.sh will ideally contain a wget command and some awk. Awk and
> > wget are installed on the linux system of the hosting provider.

>
> You're using the Borne shell to try and populate a database? Well, I'm
> sure it can be done, but you might check on other tools like maybe perl
> to do this task. There's even CPAN modules you can install do do CGI
> and database access directly from perl. And string manipulation is
> built-in.
>
> It's like you asked how to do a database program in FORTRAN IV. Sure,
> it can be done, but it's way easier to do it in other, more modern
> languages.
>
> Why did you choose the shell?
>
> --
> DeeDee, don't press that button! DeeDee! NO! Dee...


Well I like using shell scripts and I am just starting out with Perl.
I chose the shell because I wanted to get a prototype up and running
before I shift to Perl. :-)
  Réponse avec citation
Vieux 19/03/2008, 01h28   #4
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running external programs via cgi script

In article
<8efc5501-7f65-48bb-abfb-ed38e738aae0@e10g2000prf.googlegroups.com>,
newbiegalore <banerjee.anirban@gmail.com> wrote:

> Hello all :-),
> I am fairly new to writing CGI code using shell scripts. I have put
> up a site which takes an input via a form and checks a pgsql db for
> the matching entry and returns the associated fields for that. I want
> that if that entry is not found in the db I should be able to populate
> the db in real-time by running another shell script.
>
> I added the second program in the cgi-bin folder (sec.sh) and then
> tried to run it from my main cgi script. It seems that this program
> just does not run. The code works OK as I have tested on my local
> machine, I have set the permissions to 755, changed extension to .cgi
> as well and have tried to get it to work. Even if sec.sh has just echo
> "hello" > $wd/output , I can see the output file but there is nothing
> in it!!!
>
> Am I missing something crucial regarding what can be executed in the
> cgi-bin directory? Any advice would be very ful.


This question would probably be more appropriate for
comp.infosystems.www.servers.unix.

Are you running the program by full pathname or just the name of the
script? I'll bet the cgi-bin directory isn't in $PATH, so if you don't
use the full pathname you won't find it.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
Vieux 19/03/2008, 02h51   #5
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running external programs via cgi script

On 2008-03-18, newbiegalore wrote:
> Hello all :-),
> I am fairly new to writing CGI code using shell scripts. I have put
> up a site which takes an input via a form and checks a pgsql db for
> the matching entry and returns the associated fields for that. I want
> that if that entry is not found in the db I should be able to populate
> the db in real-time by running another shell script.
>
> I added the second program in the cgi-bin folder (sec.sh) and then
> tried to run it from my main cgi script. It seems that this program
> just does not run. The code works OK as I have tested on my local
> machine, I have set the permissions to 755, changed extension to .cgi
> as well and have tried to get it to work. Even if sec.sh has just echo
> "hello" > $wd/output , I can see the output file but there is nothing
> in it!!!
>
> Am I missing something crucial regarding what can be executed in the
> cgi-bin directory? Any advice would be very ful.


Either put the script in a directory in your PATH, put the cgi-bin
directory in your PATH, or call it with the full path to the file.

I usually put scripts in $HOME/bin, and add PATH=$PATH:~user/bin
to the top of the CGI script.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h17.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,49476 seconds with 13 queries