in reply to Re: (Ovid) Re: Prompting user input (newbie)
in thread Prompting user input (newbie)

lauragarcia wrote:

I'm running this program off the browser and it seems I need to be running directly from the command line.

I'm not sure I follow you. Is this supposed to be a CGI script? Is this a program someone else wrote and you are using?

If it's a relatively short program, perhaps you can post it here? Or perhaps you know enough to identify the relevant section of code and you can post that here? If so, be sure to wrap it in <CODE></CODE> tags so that the formatting is preserved.

The reason I can't answer your question directly is due to lack of information. If it's a CGI script, I need to give you information about using CGI.pm to get the data. If it's a command line program, is it expecting command line arguments or does it want to read the data from STDIN? Seeing the appropriate code sections can give us better insight as to your needs.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

  • Comment on (Ovid - CGI or command line?) Re(3): Prompting user input (newbie)

Replies are listed 'Best First'.
Re: (Ovid - CGI or command line?) Re(3): Prompting user input (newbie)
by Anonymous Monk on Apr 27, 2001 at 01:39 UTC
    I was just trying to get an input line and capture the input as a string in a simple little CGI script. I only know a little about CGI scripts, and don't know about command line programs. Obviously the following bit of code doesn't have the means to accept input:
    #!/usr/bin/perl use CGI qw/:standard/; $q=new CGI; print $q->header; print "Enter something: "; my $response = <STDIN>; print "You just entered: $response";
    So my question is two-fold: Can a CGI script accept user input other than from an HTML-based form? Secondly, how might I find out about command line program functionality? Laura
      Laura,

      What you need to understand is how the CGI process works. You have a slightly different environment to the traditional unix shell setup. While STDOUT certainly exists - if your CGI program is generating a web page "on the fly", STDOUT is what is passed back to the web server, and then to the user's browser.

      What you do have is (and I will try to show it diagramatically):

      User ======> Web Server =====> (CGI request via GET requests sees CGIExec or POST) URL page type * program gets paramaters * generates web page ohhahh<===== sends page <===== * sends page through STDOUT users back in the sees my standard http wonderful manner generated page
      So the only way for the user to interact with the cgi program is via values passed to the browser, either as part of the url (the GET method) or associated in a pseudo file (POST). If you are using CGI.pm (the recommended way), then these values are presented to your CGI program in a consistent, easy to access way.

      Hope this helps. You can look at the CGI.pm documentation at http://stein.cshl.org/WWW/software/CGI/cgi_docs.html - Lincoln Stein is probably the expert on CGI perl programs.

        OKeedokee, thanks so much for the explanation (I realize I was barking up the wrong tree...)
        laura