Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: STDIN refuses input

by GrandFather (Saint)
on Dec 16, 2013 at 01:07 UTC ( [id://1067271]=note: print w/replies, xml ) Need Help??


in reply to STDIN refuses input

What do you do to run the scripts?

It looks to me like you are running the scripts on a remote machine ("host's site"). If that is the case then your script doesn't have access to STDIN on your machine - it's a different computer!

For playing around you really should figure out how to run the scripts on your local computer. What OS are you using locally?

True laziness is hard work

Replies are listed 'Best First'.
Re^2: STDIN refuses input
by Khen1950fx (Canon) on Dec 16, 2013 at 04:29 UTC
    You could test STDIN on your local computer using CGI::Capture. Try this:
    #!perl -lw use strict; use CGI (); use CGI::Capture (); print "What is your name?"; sleep 5; SCOPE: { my $input = <STDIN>; chomp $input; my $input_ref = \$input; if ( CGI::Capture->_stdin($input_ref) ) { print "Hello, $input" or die $!; } }

      I'm not sure what you think that does, and I'm pretty sure it doesn't do what the OP wants, and I absolutely know that it's not testing STDIN in any way I think the OP is interested in. Aside from all that, I'm not the person interested in doing the testing.

      True laziness is hard work
Re^2: STDIN refuses input
by lcole (Initiate) on Dec 17, 2013 at 00:31 UTC

    You are correct. I put the script in the host's CGI-BIN, and I call the script from the HTML page. There is no box. The script will print the question, "What is your name?" Then the script should accept a response to that question. A web user would type in a response, and that response would print immediately after the words, "My name is "

    Of course there is no reason for such a dumb script except to test where to put the script (CGI-BIN) and to see that the whole script works.

    It never occurred to me that THAT script would need to execute on a local computer or browser. If I ever get by this problem, I will eventually work on a Search Box in HTML and call pre-written script which I already have. I need to feel confident that I know how to modify script and where to put it.

    Looks like this test script I copied from the Web was a bad idea. It just leaves me with questions of why it didn't work. I don't really need to use it--just understand why it doesn't work.

    Thanks again.

    lcole

      Your fundamental issue is you don't know how web servers and CGI work. It takes a bit of bending your mind around for a start and even when you think you understand what's going on there are plenty of traps lying in wait for you. You will find it helpful to read the Wikipedia CGI article. Take special note of mentions of "standard output" and "standard input".

      The key thing is that your script is running in a special "box" on the server and that STDIN and STDOUT are special. Take a deep breath, then go do some reading to get an understanding of how web pages, servers and CGI all hang together.

      True laziness is hard work

      There is no box..... Then the script should accept a response to that question.

      It is correct that there is no box. It is incorrect that the script should accept a response to that question; your script does nothing of the sort. Your script reads from STDIN. Your script doesn't produce an HTML form. It should. Without that, it will never work as you want it to in a CGI environment.

      See my post earlier in this thread. If you plan to produce a CGI script, you need to know how CGI works. Currently you do not. It's not hard to gain this understanding. But you do have to do a little research.

      There's no point in us spending all day typing up a reply here that explains how CGI works, because that has already been written many times. Start with the links I provided earlier. And understand that if you don't present the user with a form, you aren't going to get a meaningful reply.

      You may have the amplifier with a mic input, but you haven't got a microphone plugged into it yet.


      Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1067271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-29 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found