Newbie needs help- trying to submit command-line function to perl script via web 
Author Message
 Newbie needs help- trying to submit command-line function to perl script via web

I want to write a VERY simple and quick Perl file that creates an HTML
form to send information to another Perl script that already exists.
I want to write an interface to a perl script that I call on the
command line.

The entire site will be rewritten for a CMS but for right now it's in
perl.

I am not sending in the information right and I want to save all the
information that the perl script I want to run would normally send to
the command line to a file.


################
open ('deletessn.pl', ' ' . $ssn . ' delete');

$myresponse = ???
#right here I want to set a variable called myresponse that takes the
information that deletessn.pl sends back to the screen/command line
and then save it to the file below- will $STDOUT work?

open(OUT, ">>/opt/ns-server/www/hrsc/error.txt");
print OUT "$myresponse\n";
close(OUT);
################

THANKS for any help from a non-Perl programmer!!!!!!!

Don



Fri, 13 May 2005 17:27:21 GMT  
 Newbie needs help- trying to submit command-line function to perl script via web
Is everyone as confused as I am?
Do you mean that you want to post a url form to the web from command line,
and then grab the response and save to a file?
If so try the LWP::Simple module from CPAN.
If not you need to clarify more for this blockhead.

Thanks,
Rodney


Quote:
> I want to write a VERY simple and quick Perl file that creates an HTML
> form to send information to another Perl script that already exists.
> I want to write an interface to a perl script that I call on the
> command line.

> The entire site will be rewritten for a CMS but for right now it's in
> perl.

> I am not sending in the information right and I want to save all the
> information that the perl script I want to run would normally send to
> the command line to a file.


> ################
> open ('deletessn.pl', ' ' . $ssn . ' delete');

> $myresponse = ???
> #right here I want to set a variable called myresponse that takes the
> information that deletessn.pl sends back to the screen/command line
> and then save it to the file below- will $STDOUT work?

> open(OUT, ">>/opt/ns-server/www/hrsc/error.txt");
> print OUT "$myresponse\n";
> close(OUT);
> ################

> THANKS for any help from a non-Perl programmer!!!!!!!

> Don



Fri, 13 May 2005 17:37:49 GMT  
 Newbie needs help- trying to submit command-line function to perl script via web

Quote:

> I want to write a VERY simple and quick Perl file that creates an HTML
> form to send information to another Perl script that already exists.

To send the info to a *CGI program* or to a Perl script?

They are not the same thing. They take input differently.
The answer will be different depending on which it is that
your really want.

Which one do you really want?

If you want to "fill out" forms and submit the info to a CGI
program (whether written in Perl or not), you can use this
module to make your Perl program "look like" a web browser
to the CGI program's web server:

   use LWP::UserAgent;

http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/LWP/UserAgent.pm

If you want to run a Perl script, then use system() or backticks.

Quote:
> The entire site

What site?

Your site or the site that you want to communicate with?

Quote:
> will be rewritten for a CMS

What is a CMS?

Quote:
> I am not sending in the information right and I want to save all the
> information that the perl script I want to run would normally send to
> the command line to a file.

Huh?

Quote:

> ################
> open ('deletessn.pl', ' ' . $ssn . ' delete');

That does not run the deletessn.pl program.

Does deletessn.pl support GET or POST or both?

Is it written using the CGI.pm module?

Or is it written as a command line program that takes
command line arguments?

Quote:
> $myresponse = ???

If deletessn.pl is a normal (non-CGI) program, then
you can run it and capture its outputs using backwards
single quotes (backticks):

   my $output_from_deletessn = `deletessn.pl $ssn delete`;
or
   my $output_from_deletessn = qx/deletessn.pl $ssn delete/;

If it is a CGI program that you don't want to run in a CGI
environment, then you must supply its input in an env var
(GET) or from STDIN (POST). This will be really easy to do
if deletessn.pl uses the CGI.pm module.

If it is a CGI program that you want to run in a CGI
environment, then use UserAgent.

Quote:
> open(OUT, ">>/opt/ns-server/www/hrsc/error.txt");

You should always, yes *always*, check the return value from open():

   open(OUT, ">>/opt/ns-server/www/hrsc/error.txt")
      or die "could not open '/opt/ns-server/www/hrsc/error.txt'  $!";

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Fri, 13 May 2005 18:46:41 GMT  
 Newbie needs help- trying to submit command-line function to perl script via web
hmm... it does seem like we are on different ends of the development
spectrum!  If you don't use CMSs in your daily life then you don't do
development like I do.  Content Management Systems are used in like
all of the Fortune 500 companies and people on my team must use the
term CMS a dozen times a day.  I have a contract that has about 4k
static html pages that we're quickly moving to a CMS.  You generally
need to run a CMS if you have 30-40 stakeholders or writers who you
don't want to have root access to your servers.

Similarly it sounds like you use the term CGI often and I haven't
heard that since 1996.

HOWEVER, thanks for responding and I will take a look at the
information you gave me.

Because I know nothing about the general architecture of PERL scripts
on a network, I am not surprised that I described things incorrectly.
I worked with NT-based solutions for the last 8 years and terms like
"batch files that mimic the command line interface" get tossed around
a lot.

What I want to do is-- inside a PERL file, I want to send information
to another file written in PERL.  That second PERL file will return a
response.  That second file was written as a standalone file to be run
from the command line in Unix.

I tried to send the command to this second file by using OPEN.
Clearly that's not working.  In order to see what the heck was going
on, I tried to capture the response that the second file returns to
the screen.  To be honest, I have no idea if that's possible.

In some respects, yes, this is probably a CGI by your standards.  I
receive data from the users, check the apache user database (using
code that I swiped) and if there is a user there then I want to delete
that user.  Problem is that when I originally tried to do this, my
code to communicate with dbmmanage didn't work and no errors were
generated.  I don't know how to debug in PERL.  So, sez I, I'll use
the existing PERL file that we use to delete records by hand.  I want
to send data from my file to that file.  I would also like to capture
the response that this file normally sends out.

thanks!

Don

Quote:


> > I want to write a VERY simple and quick Perl file that creates an HTML
> > form to send information to another Perl script that already exists.

> To send the info to a *CGI program* or to a Perl script?

> They are not the same thing. They take input differently.
> The answer will be different depending on which it is that
> your really want.

> Which one do you really want?

> If you want to "fill out" forms and submit the info to a CGI
> program (whether written in Perl or not), you can use this
> module to make your Perl program "look like" a web browser
> to the CGI program's web server:

>    use LWP::UserAgent;

> http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/LWP/UserAgent.pm

> If you want to run a Perl script, then use system() or backticks.

> > The entire site

> What site?

> Your site or the site that you want to communicate with?

> > will be rewritten for a CMS

> What is a CMS?

> > I am not sending in the information right and I want to save all the
> > information that the perl script I want to run would normally send to
> > the command line to a file.

> Huh?


> > ################
> > open ('deletessn.pl', ' ' . $ssn . ' delete');

> That does not run the deletessn.pl program.

> Does deletessn.pl support GET or POST or both?

> Is it written using the CGI.pm module?

> Or is it written as a command line program that takes
> command line arguments?

> > $myresponse = ???

> If deletessn.pl is a normal (non-CGI) program, then
> you can run it and capture its outputs using backwards
> single quotes (backticks):

>    my $output_from_deletessn = `deletessn.pl $ssn delete`;
> or
>    my $output_from_deletessn = qx/deletessn.pl $ssn delete/;

> If it is a CGI program that you don't want to run in a CGI
> environment, then you must supply its input in an env var
> (GET) or from STDIN (POST). This will be really easy to do
> if deletessn.pl uses the CGI.pm module.

> If it is a CGI program that you want to run in a CGI
> environment, then use UserAgent.

> > open(OUT, ">>/opt/ns-server/www/hrsc/error.txt");

> You should always, yes *always*, check the return value from open():

>    open(OUT, ">>/opt/ns-server/www/hrsc/error.txt")
>       or die "could not open '/opt/ns-server/www/hrsc/error.txt'  $!";



Sat, 14 May 2005 04:07:45 GMT  
 Newbie needs help- trying to submit command-line function to perl script via web

[ TOFU quoting style repaired (somewhat) ]

Quote:



>> > I want to write a VERY simple and quick Perl file that creates an HTML
>> > form to send information to another Perl script that already exists.

>> To send the info to a *CGI program* or to a Perl script?

>> They are not the same thing. They take input differently.
>> The answer will be different depending on which it is that
>> your really want.

>> Which one do you really want?
>> If you want to run a Perl script, then use system() or backticks.
>> > will be rewritten for a CMS

>> What is a CMS?
>> you can run it and capture its outputs using backwards
>> single quotes (backticks):

>>    my $output_from_deletessn = `deletessn.pl $ssn delete`;
>> or
>>    my $output_from_deletessn = qx/deletessn.pl $ssn delete/;
> hmm... it does seem like we are on different ends of the development
> spectrum!  

What is the development spectrum?

Is one end harder or more complicated, or is it some other
quality that is spread across some spectrum?

Quote:
> If you don't use CMSs in your daily life then you don't do
> development like I do.

I've programmed in Perl daily for about eight years.

Almost none of that programming was CGI programs.

Perl has a million and one uses, CGI is only one of them.

Quote:
> don't want to have root access to your servers.

There are most often no "web servers" involved in my Perl programming.

Quote:
> HOWEVER, thanks for responding and I will take a look at the
> information you gave me.

Here's some more, the Posting Guidelines that are posted here weekly:

   http://mail.augustmail.com/~tadmc/clpmisc.shtml

Quote:
> Because I know nothing about the general architecture of PERL scripts

                                                           ^^^^

Quote:
> on a network,

You mean Perl scripts.

You were spelling it correctly before, don't change to the wrong way. :-)

See the Perl FAQ:

   What's the difference between "perl" and "Perl"?

Quote:
> I am not surprised that I described things incorrectly.

Precise terminology is essential when discussing technical topics.

If you ask the wrong question, you'll get the wrong answer.

Quote:
> I worked with NT-based solutions for the last 8 years

Everybody has problems.  :-)  :-)

Quote:
> What I want to do is-- inside a PERL file, I want to send information
> to another file written in PERL.  

Stop talking about files "doing" things.

Files are storage. You can store programs in files, but the files
do not "do" anything.

"programs" (or "processes") do things.

Data (stored in files or not) does not "do" things, it
"has things done to it".

Quote:
> That second PERL file will return a
> response.  That second file was written as a standalone file to be run
> from the command line in Unix.

Then I've already told you what you need to know.

Quote:
> In some respects, yes, this is probably a CGI by your standards.  

Your misuse of terminology leads me to believe that your
understanding of how this technology works might also need
some improvement.

Your program either runs in a CGI environment or it does not.

There are no personal "standards" involved.

Quote:
> I would also like to capture
> the response that this file normally sends out.

I've already answered your question in my earlier followup.

Did you try it?

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sat, 14 May 2005 05:17:34 GMT  
 Newbie needs help- trying to submit command-line function to perl script via web
Not that we don't understand the CMS term. I myself have written many hooks,
interfaces
into some of the well known CMS systems. It sounds as if this is your
scenario.

A perl script that is evoked via an apache front end runs, checks blah blah
for user.
Then executes another perl script with that information to delete the user.

The second file then responds to the original post to remove the user.

First of all that's too complicated.

From your initial script just call the second perl file with backticks.

my $command=`/path/to/perl/interp/perl
/path/to/second/perl/file/secondfile.pl $input $more_input
$even_more_input`;

Then the results of running the second script are contained within the
scalar $command
Then just send back to the client via normal methods or parse and replace
text etc...

This sound like what you want?


Quote:
> hmm... it does seem like we are on different ends of the development
> spectrum!  If you don't use CMSs in your daily life then you don't do
> development like I do.  Content Management Systems are used in like
> all of the Fortune 500 companies and people on my team must use the
> term CMS a dozen times a day.  I have a contract that has about 4k
> static html pages that we're quickly moving to a CMS.  You generally
> need to run a CMS if you have 30-40 stakeholders or writers who you
> don't want to have root access to your servers.

> Similarly it sounds like you use the term CGI often and I haven't
> heard that since 1996.

> HOWEVER, thanks for responding and I will take a look at the
> information you gave me.

> Because I know nothing about the general architecture of PERL scripts
> on a network, I am not surprised that I described things incorrectly.
> I worked with NT-based solutions for the last 8 years and terms like
> "batch files that mimic the command line interface" get tossed around
> a lot.

> What I want to do is-- inside a PERL file, I want to send information
> to another file written in PERL.  That second PERL fe will return a
> response.  That second file was written as a standalone file to be run
> from the command line in Unix.

> I tried to send the command to this second file by using OPEN.
> Clearly that's not working.  In order to see what the heck was going
> on, I tried to capture the response that the second file returns to
> the screen.  To be honest, I have no idea if that's possible.

> In some respects, yes, this is probably a CGI by your standards.  I
> receive data from the users, check the apache user database (using
> code that I swiped) and if there is a user there then I want to delete
> that user.  Problem is that when I originally tried to do this, my
> code to communicate with dbmmanage didn't work and no errors were
> generated.  I don't know how to debug in PERL.  So, sez I, I'll use
> the existing PERL file that we use to delete records by hand.  I want
> to send data from my file to that file.  I would also like to capture
> the response that this file normally sends out.

> thanks!

> Don




- Show quoted text -

Quote:

> > > I want to write a VERY simple and quick Perl file that creates an HTML
> > > form to send information to another Perl script that already exists.

> > To send the info to a *CGI program* or to a Perl script?

> > They are not the same thing. They take input differently.
> > The answer will be different depending on which it is that
> > your really want.

> > Which one do you really want?

> > If you want to "fill out" forms and submit the info to a CGI
> > program (whether written in Perl or not), you can use this
> > module to make your Perl program "look like" a web browser
> > to the CGI program's web server:

> >    use LWP::UserAgent;

> > http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/LWP/UserAgent.pm

> > If you want to run a Perl script, then use system() or backticks.

> > > The entire site

> > What site?

> > Your site or the site that you want to communicate with?

> > > will be rewritten for a CMS

> > What is a CMS?

> > > I am not sending in the information right and I want to save all the
> > > information that the perl script I want to run would normally send to
> > > the command line to a file.

> > Huh?


> > > ################
> > > open ('deletessn.pl', ' ' . $ssn . ' delete');

> > That does not run the deletessn.pl program.

> > Does deletessn.pl support GET or POST or both?

> > Is it written using the CGI.pm module?

> > Or is it written as a command line program that takes
> > command line arguments?

> > > $myresponse = ???

> > If deletessn.pl is a normal (non-CGI) program, then
> > you can run it and capture its outputs using backwards
> > single quotes (backticks):

> >    my $output_from_deletessn = `deletessn.pl $ssn delete`;
> > or
> >    my $output_from_deletessn = qx/deletessn.pl $ssn delete/;

> > If it is a CGI program that you don't want to run in a CGI
> > environment, then you must supply its input in an env var
> > (GET) or from STDIN (POST). This will be really easy to do
> > if deletessn.pl uses the CGI.pm module.

> > If it is a CGI program that you want to run in a CGI
> > environment, then use UserAgent.

> > > open(OUT, ">>/opt/ns-server/www/hrsc/error.txt");

> > You should always, yes *always*, check the return value from open():

> >    open(OUT, ">>/opt/ns-server/www/hrsc/error.txt")
> >       or die "could not open '/opt/ns-server/www/hrsc/error.txt'  $!";



Sat, 14 May 2005 05:32:38 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Passing Args to script via web and command line

2. Need Help submitting hidden values to .cfm via PERL

3. Newbie trying to pass filenames from command line??

4. Run perl script on web server from command line

5. Need help trying to do multi-line regexp

6. perl newbie: need help pasing web forms

7. Newbie needs mentor for web perl scripts

8. Newbie needs simple perl script for web page

9. (???) Accessing the command line from inside a script (Yes, I'm a newbie)

10. connecting to a Mysql via command line ok FAILs with perl

11. Submit form via script?

12. Need help with NT Web server and Perl scripts

 

 
Powered by phpBB® Forum Software