FAQ 8.31 Can I use perl to run a telnet or ftp session?


This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
Posted On: Sunday 11th of November 2012 08:31:04 PM Total Views:  118
View Complete with Replies

RELATED TOPICS OF Perl PROGRAMMING LANGUAGE




FAQ 8.31 Can I use perl to run a telnet or ftp session?

This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 8.31: Can I use perl to run a telnet or ftp session Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from CPAN). http://www.cpan.org/scripts/netstuff/telnet.emul.shar will also help for emulating the telnet protocol, but Net::Telnet is quite probably easier to use.. If all you want to do is pretend to be telnet but don't need the initial telnet handshaking, then the standard dual-process approach will suffice: use IO::Socket; # new in 5.004 $handle = IO::Socket::INET->new('www.perl.com:80') or die "can't connect to port 80 on www.perl.com: $!"; $handle->autoflush(1); if (fork()) { # XXX: undef means failure select($handle); print while ; # everything from stdin to socket } else { print while ; # everything from socket to stdout } close $handle; exit; -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

96

Posted on:

Tuesday 16th October 2012
View Replies!

FAQ 8.31 Can I use perl to run a telnet or ftp session?

This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 8.31: Can I use perl to run a telnet or ftp session Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from CPAN). http://www.cpan.org/scripts/netstuff/telnet.emul.shar will also help for emulating the telnet protocol, but Net::Telnet is quite probably easier to use.. If all you want to do is pretend to be telnet but don't need the initial telnet handshaking, then the standard dual-process approach will suffice: use IO::Socket; # new in 5.004 $handle = IO::Socket::INET->new('www.perl.com:80') or die "can't connect to port 80 on www.perl.com: $!"; $handle->autoflush(1); if (fork()) { # XXX: undef means failure select($handle); print while ; # everything from stdin to socket } else { print while ; # everything from socket to stdout } close $handle; exit; -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

118

Posted on:

Monday 5th November 2012
View Replies!

FAQ 8.31 Can I use perl to run a telnet or ftp session?

This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 8.31: Can I use perl to run a telnet or ftp session Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from CPAN). http://www.cpan.org/scripts/netstuff/telnet.emul.shar will also help for emulating the telnet protocol, but Net::Telnet is quite probably easier to use.. If all you want to do is pretend to be telnet but don't need the initial telnet handshaking, then the standard dual-process approach will suffice: use IO::Socket; # new in 5.004 $handle = IO::Socket::INET->new('www.perl.com:80') or die "can't connect to port 80 on www.perl.com: $!"; $handle->autoflush(1); if (fork()) { # XXX: undef means failure select($handle); print while ; # everything from stdin to socket } else { print while ; # everything from socket to stdout } close $handle; exit; -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

77

Posted on:

Wednesday 7th November 2012
View Replies!

FAQ 4.65 How can I store a multidimensional array in a DBM file?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

79

Posted on:

Saturday 10th November 2012
View Replies!

file.lock")?" style="color:#1385b4;text-transform:uppercase;" name="Post_237552"> FAQ 5.21 Why can't I just open(FH, ">file.lock")?

This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

51

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 5.8 How can I make a filehandle local to a subroutine? How do I pass filehandles between subroutines? How do I make an array of filehandles?

This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

117

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 4.31 How can I split a [character] delimited string except when inside [character]?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

95

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 4.9 How can I output Roman numerals?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

96

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 3.12 Where can I get perl-mode for emacs?

This is an excerpt from the latest version perlfaq3.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

87

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 2.15 Where can I buy a commercial version of perl?

This is an excerpt from the latest version perlfaq2.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

116

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 2.8 Where can I get information on Perl?

This is an excerpt from the latest version perlfaq2.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

262

Posted on:

Saturday 10th November 2012
View Replies!

new Thread cannot work

buddies. The code below can't work on my WindowsXP with SP2: =============== #!/usr/bin/perl use Thread qw/async yield/; my $var = 0; sub abump { lock $var; if ($var == 0) { yield; $var++; } } my $t1 = new ...
VIEWS ON THIS POST

141

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 8.24 Why can't I get the output of a command with system()?

This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

102

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 7.26 How can I find out my current package?

This is an excerpt from the latest version perlfaq7.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

104

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 6.7 How can I match a locale-smart version of "/[a-zA-Z]/"?

This is an excerpt from the latest version perlfaq6.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

66

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 5.28 How can I read in an entire file all at once?

This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

85

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 5.5 How can I copy a file?

This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

100

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 4.60 How can I always keep my hash sorted?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

169

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 9.3 How can I get better error messages from a CGI program?

This is an excerpt from the latest version perlfaq9.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

123

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 8.16 How can I sleep() or alarm() for under a second?

This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

114

Posted on:

Saturday 10th November 2012
View Replies!