Hi Vrunda,
Can you post the script that responds to the CGI request?
How are you passign the parameters from the CGI bit to the telnet bit? You
say that it times out waiting for the input of the username and password.
This is the bit that confuses me.
Gary
On Thursday 28 June 2001 6:13 pm, Prabhu, Vrunda P (UMC-Student) wrote:
> Thanks Gary,
> Here are some of the answers:
>
> I have a simple script (code follows) that when I run at the prompt, lists
> the files in the directory as it is supposed to. Next, rather than
> programmatically including the username and password, I wrote an HTML form
> that requests the two, and then calls a CGI that parses username and
> password, which then (I expect) should do exactly what the script below is
> doing. However, when I enter the username and password and press the
> SUbmit button, I get internal server error.
>
> **********
> #!/usr/bin/perl
> use Net::Telnet ();
>
> $ip = '...';
> $username='...';
> $password='...';
> $t=new Net::Telnet(Prompt=>'/\[.*\]\$ $/');
> $t->open($ip);
> $t->login($username, $password);
> @files=$t->cmd("ls -alg");
> print @files;
> $t->close;
> ************
>
> >Hi Vrunda,
> >
> >I can't see why wrapping a CGI around your script should introduce a
>
> timeout.
>
> >Presumably other CGI's work fine, and if you run the original command
> >line
> >one it still works? Does the command line one run in the same user ID
> >and on
> >the same server?
>
> Other CGI's work fine. If I try to run the modified CGI at the command
> prompt, it times out because it is waiting for the input of username and
> password.
>
> >How are you detecting the timeout, is it being detected by your code, or
> >is
> >the script just dieing?
> >
> >Have you put some debugging info into the server error logs?
>
> How can I do that? NO, right now there is no debugging info.
>
>
>
> If so, what
> do
> they say?
>
> Hope these questions help, if not get back to the list with some more
> details.
>
> Gary
>
> On Wednesday 27 June 2001 7:57 pm, Vrunda Prabhu wrote:
> > Thanks Gary,
> > I got back to my work yesterday, and modified th eport number, spent a
> > long time getting the prompt to work, but now can make a connection.
> >
> > Question:
> > If I run the program at the command prompt and ask for a listing of
> > files in the directory for example, it does that. In this code
> > however, I have entered the username and password, and want to avoid
>
> this
>
> > situation. So I wrote a HTML form that the user could enter his/her
>
> name
>
> > and password, and this form would call the cgi, and proceed as before.
> > HOwever, as soon as I do this, I run into a timeout error again. Can
>
> this
>
> > be rectified easily?
> >
> >
> > Thanks for any help in advance.
> > Vrunda
> >
> > On Mon, 25 Jun 2001, Gary Stainburn wrote:
> > > Hi Vrunda,
> > >
> > > I've just re-read the message and noticed you're trying to use the
>
> POP
>
> > > protocol. To do that you need to use port 110.
> > >
> > > Before trying to do it with your script tho', try doing it directly
>
> by
>
> > > calling the telnet program. If that doesn't work, your script won't
> > > stand a chance.
> > >
> > > For a full list of ports and services look at the services file on
>
> your
>
> > > box (/etc/services on most unix systems \windows\services under
>
> windows.
>
> > > Gary
> > >
> > > On Friday 22 June 2001 4:39 pm, Prabhu, Vrunda P (UMC-Student)
>
> wrote:
> > > > Gary:
> > > > I used port 23 with the same outcome: read timed out.
> > > >
> > > > John Edwards (thanks very much John) suggested a document at :
> > > > http://www.perlfect.com/articles/telnet.shtml
> > > >
> > > > which seems to be pretty good, an dmight have solutions.
> > > > Vrunda
> > > >
> > > > -----Original Message-----
> > > > From: Gary Stainburn
> > > > To: Prabhu, Vrunda P (UMC-Student); '[EMAIL PROTECTED] '
> > > > Sent: 6/22/01 10:31 AM
> > > > Subject: Re: :Telnet
> > > >
> > > > Hi,
> > > >
> > > > why are you telnetting to port 80? That's the http port.
> > > > To use telnet, use port 23, which I think is the default anyway.
> > > >
> > > > Gary
> > > >
> > > > On Friday 22 June 2001 4:07 pm, Prabhu, Vrunda P (UMC-Student)
>
> wrote:
> > > > > I too have questions on the same topic - Net::Telnet. I tried
>
> the
>
> > > > > following code: (I have deleted the hostname, username and
>
> passwd),
>
> > > > and get
> > > >
> > > > > the error:
> > > > >
> > > > > read timed-out at ./teltry.cgi line 13
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > #!/usr/bin/perl
> > > > >
> > > > > my ($hostname, $line, $passwd, $pop, $username);
> > > > >
> > > > > $hostname="...";
> > > > > $username="...";
> > > > > $passwd="...";
> > > > >
> > > > > use Net::Telnet ();
> > > > > $pop=new Net::Telnet (Telnetmode => 0);
> > > > > $pop->open(Host => $hostname, Port =>80);
> > > > >
> > > > > $line= $pop->getline;
> > > > > die $line unless $line=~/^\+OK/;
> > > > > $pop->print("user $username");
> > > > > $line = $pop->getline;
> > > > > die $line unless $line =~/^\+OK/;
> > > > > $pop->print("pass $passwd");
> > > > > $line=$pop->getline;
> > > > >
> > > > > Thanks in advance for any and all suggestions. My aim is to be
>
> able
>
> > > > to
> > > >
> > > > > telnet to a site, and once there work allow the user to work at
>
> the
>
> > > > site,
> > > >
> > > > > till the time when the user might wish to telnet to another
>
> site. If
>
> > > > the
> > > >
> > > > > second site is connected to the first, the program shoudl make
>
> an
>
> > > > internal
> > > >
> > > > > check, and allow the user to telnet there without asking for
>
> his/her
>
> > > > > username password again.
> > > > > I as you see in the code above am at the very early stages of
> > > >
> > > > attempting to
> > > >
> > > > > connect to a remote site.
> > > > >
> > > > > Thanks again.
> > > > > Vrunda
> > > > >
> > > > > -----Original Message-----
> > > > > From: Tom Yarrish
> > > > > To: [EMAIL PROTECTED]
> > > > > Sent: 6/21/01 3:22 PM
> > > > > Subject: Net::Telnet
> > > > >
> > > > > Hey all,
> > > > > Okay, I'm playing with Net::Telnet, and I've gotten to the point
> > > > > where
> > > >
> > > > I
> > > >
> > > > > connect to the other machine. What I wanted to know is, can I
>
> run
>
> > > > > and interact with a program just using the cmd() part of that
>
> module?
>
> > > > > Or
> > > >
> > > > do
> > > >
> > > > > I
> > > > > need to use another module to do that. Basically what I'm going
>
> is
>
> > > > > telnetting to a server, then running a program (perl scripts
> > > >
> > > > actually),
> > > >
> > > > > then feeding it some options, and then exiting out of the
>
> program.
>
> > > > Sort
> > > >
> > > > > of like this (snipped)
> > > > >
> > > > > $session->cmd("/home/export/user/Xmenu.pl");
> > > > > $session->cmd("2"); # This is fed to the Xmenu.pl program
> > > > > $session->cmd("1"); # and this
> > > > > $session->cmd("y"); # and this
> > > > >
> > > > > Thanks,
> > > > > Tom
> > >
> > > --
> > > Gary Stainburn
> > >
> > > This email does not contain private or confidential material as it
> > > may be snooped on by interested government parties for unknown
> > > and undisclosed purposes - Regulation of Investigatory Powers Act,
>
> 2000
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000