<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl code to transfer text strings. Need to transfer file. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880104#M279945</link>
    <description>Actually, Net::FTP does not require a hardcoded password. It is perfectly capable of reading a .netrc file just as any FTP client can.</description>
    <pubDate>Tue, 17 Oct 2006 15:29:58 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2006-10-17T15:29:58Z</dc:date>
    <item>
      <title>Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880098#M279939</link>
      <description>Does anyone know how to change this perl code&lt;BR /&gt;below to transfer a file and not just text&lt;BR /&gt;strings. Two parts. A client socket part and&lt;BR /&gt;a server socket(daemon) part.&lt;BR /&gt;&lt;BR /&gt;socket.client.pl&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;#===============================================&lt;BR /&gt;# Client -- using object interface&lt;BR /&gt;# Support Windows and UNIX&lt;BR /&gt;#===============================================&lt;BR /&gt;use IO::Socket;&lt;BR /&gt;my $sock = new IO::Socket::INET (&lt;BR /&gt;    PeerAddr =&amp;gt; '128.166.11.28',&lt;BR /&gt;    PeerPort =&amp;gt; '9999',&lt;BR /&gt;    Proto =&amp;gt; 'tcp',&lt;BR /&gt;);&lt;BR /&gt;die "Could not create socket: $!\n" unless $sock;&lt;BR /&gt;print $sock "Hi there!\n";&lt;BR /&gt;$sock-&amp;gt;send("Hi again!\n");&lt;BR /&gt;&lt;BR /&gt;close($sock);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;socket.server.pl - enclosed also.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;#===============================================&lt;BR /&gt;# Server -- using object interface&lt;BR /&gt;# Support Windows and UNIX&lt;BR /&gt;#===============================================&lt;BR /&gt;&lt;BR /&gt;#use Proc::Daemon;&lt;BR /&gt;use IO::Socket;&lt;BR /&gt;#Proc::Daemon::Init();&lt;BR /&gt;&lt;BR /&gt;use POSIX qw(setsid);&lt;BR /&gt;&lt;BR /&gt;sub daemonize {&lt;BR /&gt;    die "Can't fork" unless defined (my $child = fork());&lt;BR /&gt;exit 0 if $child;&lt;BR /&gt;setsid();&lt;BR /&gt;open(STDIN, "open(STDOUT, "&amp;gt;/dev/null");&lt;BR /&gt;open(STDERR, "&amp;gt;&amp;amp;STDOUT");&lt;BR /&gt;chdir '/';&lt;BR /&gt;umask(0);&lt;BR /&gt;$ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin';&lt;BR /&gt;return $$;&lt;BR /&gt;                };&lt;BR /&gt;&lt;BR /&gt;&amp;amp;daemonize;&lt;BR /&gt;while() {&lt;BR /&gt;my $sock = new IO::Socket::INET (&lt;BR /&gt;LocalAddr =&amp;gt; '128.166.11.28',&lt;BR /&gt;LocalPort =&amp;gt; '9999',&lt;BR /&gt;   Proto =&amp;gt; 'tcp',&lt;BR /&gt;      Listen =&amp;gt; 5,&lt;BR /&gt;      Reuse =&amp;gt; 1,&lt;BR /&gt;                                );&lt;BR /&gt;&lt;BR /&gt;  die "Could not create socket: $!\n" unless $sock;&lt;BR /&gt;&lt;BR /&gt;  my $new_sock = $sock-&amp;gt;accept();&lt;BR /&gt;&lt;BR /&gt;####################################&lt;BR /&gt;#   Put a message to file.          #&lt;BR /&gt;####################################&lt;BR /&gt;&lt;BR /&gt;while(defined($Line = &amp;lt;$new_sock&amp;gt;)) {&lt;BR /&gt; open (F,"+&amp;gt;&amp;gt;/var/adm/syslog/socket.server.perl.log");&lt;BR /&gt;print F $Line;&lt;BR /&gt;system($Line);&lt;BR /&gt; close F;&lt;BR /&gt;                                    };&lt;BR /&gt;    close($sock);&lt;BR /&gt;};  #End of while cycle&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Oct 2006 15:43:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880098#M279939</guid>
      <dc:creator>jerry1</dc:creator>
      <dc:date>2006-10-13T15:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880099#M279940</link>
      <description>Jerry,&lt;BR /&gt;not quite sure what you mean. YOu can not "transfer" a file via a socket, but you can transfer the file contents via the socket.&lt;BR /&gt;If that is what you want to do, you should be able to enclose your &lt;BR /&gt;print $sock "Hi there!\n";&lt;BR /&gt;$sock-&amp;gt;send("Hi again!\n");&lt;BR /&gt;statements with a loop, which read the input file line by line.</description>
      <pubDate>Mon, 16 Oct 2006 02:05:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880099#M279940</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-16T02:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880100#M279941</link>
      <description>I did not know it was not possible to&lt;BR /&gt;just transfer a file. If only the contents&lt;BR /&gt;of the file, line by line can be transfered, then I would not know how to do that since&lt;BR /&gt;my perl coding sucks. &lt;BR /&gt;</description>
      <pubDate>Mon, 16 Oct 2006 14:55:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880100#M279941</guid>
      <dc:creator>jerry1</dc:creator>
      <dc:date>2006-10-16T14:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880101#M279942</link>
      <description>It's even a little more complicated than that because not all files are textfiles so the concept of a "line" may not exist for some files. Moreover, reading a "line" of text and sending it via a pipe is trivially simple but the receiving process also has to acknowledge that it received that line (or more commonly a block of data) and is ready for another or it has not fully received the data or the data are garbled and need to be re-sent. None of this is very difficult. &lt;BR /&gt;&lt;BR /&gt;The good news is that it really isn't necessary to reinvent the wheel; just use the Net::FTP module and everything will be done for you. If you like, you can choose a non-standard port. Also (and I have not bothered to search because I do not reward laziness), if there is a need for some task there is likely already a module to do that task (or something very close to it). Search the modules at &lt;A href="http://www.perl.org/CPAN" target="_blank"&gt;www.perl.org/CPAN&lt;/A&gt; and you may very well find exactly what you are looking for.&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Oct 2006 08:53:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880101#M279942</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-10-17T08:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880102#M279943</link>
      <description>First, if you can afford the time&lt;BR /&gt;I would suggest to have a deko at "perldoc perlipc".&lt;BR /&gt;It explains the basics of inet socket IPC with lots of valuable code snippets in Perl.&lt;BR /&gt;I'm sure it will spark an idea.&lt;BR /&gt; &lt;BR /&gt;Basically it doesn't matter what kind of data you send over a socket pair wire, be it ascii or binary.&lt;BR /&gt;Only does your client need to know how to handle it.&lt;BR /&gt;For instance the client could even read per single byte via a sysread() in a while loop,&lt;BR /&gt;though this is not terribly efficient,&lt;BR /&gt;as is also constated in the above mentioned POD.&lt;BR /&gt;But as Clay mentioned, why do you want to burden yourself with typical socket coding morass like establishing a proper protocol,&lt;BR /&gt;preventing deadlocks, struggling with buffering issues (n.b. don't forgot to autoflush either via $|, or the autoflush method of IO::Handle) while there are lots of higher tcp level modules available whose authors already have gone through all this?&lt;BR /&gt;Well, maybe self-education, or very specific needs would justify it?&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Oct 2006 10:33:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880102#M279943</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2006-10-17T10:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880103#M279944</link>
      <description>I could use Expect or the Perl module&lt;BR /&gt;Net::FTP or even just a shell script, which&lt;BR /&gt;I use all of them today, which I just pass &lt;BR /&gt;parms to. But they all require a login id&lt;BR /&gt;and password. Which they do not want &lt;BR /&gt;hardcoded in any script. Guess I could &lt;BR /&gt;just use Openssh scp .&lt;BR /&gt;&lt;BR /&gt;Thanks for you inputs.</description>
      <pubDate>Tue, 17 Oct 2006 15:21:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880103#M279944</guid>
      <dc:creator>jerry1</dc:creator>
      <dc:date>2006-10-17T15:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880104#M279945</link>
      <description>Actually, Net::FTP does not require a hardcoded password. It is perfectly capable of reading a .netrc file just as any FTP client can.</description>
      <pubDate>Tue, 17 Oct 2006 15:29:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880104#M279945</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-10-17T15:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Perl code to transfer text strings. Need to transfer file.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880105#M279946</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Security note: ftp authenticates in clear text.&lt;BR /&gt;&lt;BR /&gt;.netrc files contents can become known compromising security on the server.&lt;BR /&gt;&lt;BR /&gt;Always disable root ftp on your servers.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 17 Oct 2006 16:16:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-code-to-transfer-text-strings-need-to-transfer-file/m-p/3880105#M279946</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-10-17T16:16:18Z</dc:date>
    </item>
  </channel>
</rss>

