What if I have a variable like 'state' (for example) which I set to 1 when
a
telnet connection is requested.  Within the cgi, I have a while loop that
keeps the telnet connection open while 'state' is 1.  The value of 'state'
would be changed by the cgi.  Does this sound as a right direction?  I am
still unclear about how to open a telnet session in a new window.

Thanks again
Vrunda

On Tue, 3 Jul 2001, Gary Stainburn wrote:

> Hi Vrunda,
> 
> I won't say that what you want can't be done, but it will be very hard.  
> Because of the way http and CGI work there is not 'state' between 
> connections.  As far as the web server's concerned, each connection is a new 
> connection, and after it's finished providing your content it stops.  This 
> means that you can't have a perl script running across 4 pages, so you can't 
> leave a telnet connection open.
> 
> Gary
> 
> On Tuesday 03 July 2001  4:53 pm, Prabhu, Vrunda P (UMC-Student) wrote:
> > Hello Gary,
> > I can get my telnet session to work now.  I run a HTML form which calls a
> > CGI (that contains the telnet command).  The CGI parses the username and
> > password, and I have a telnet session.  Works well.  All I am doing in the
> > actual telnet session is listing the files in the root directory.
> >
> > My next task is to establish a telnet session which closes only upon
> > instruction from the user.  There have been about 3-4 telnet-related
> > queries on the list in the past few days.
> >
> > Would it be possible for the Perl Gurus to shed some light on this matter?
> > The documents on CPAn do not have too much in terms of proceeding beyond
> > the basics.
> >
> > Thanks very much Gary and others .
> >
> > Vrunda
> >
> >
> > 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     
> 

Reply via email to