perl.beginners https://www.nntp.perl.org/group/perl.beginners/ ... Copyright 1998-2018 perl.org Fri, 23 Feb 2018 00:29:07 +0000 ask@perl.org Re: ssh::command by Lancelot Mak thx for the msg. but I &#39;m not looking for cfg mgmt tools. <br/> <br/>On 19 February 2018 at 18:41, Alex Mestiashvili &lt;amestia@rsh2.donotuse.de&gt; <br/>wrote: <br/> <br/>&gt; On 02/14/2018 08:48 AM, Lancelot Mak wrote: <br/>&gt; &gt; thanks for the help. <br/>&gt; &gt; it works. <br/>&gt; &gt; <br/>&gt; &gt; On 14 February 2018 at 13:33, &ETH;&#152;&ETH;&raquo;&Ntilde;&#140;&Ntilde;&#143; &ETH;&nbsp;&ETH;&deg;&Ntilde;&#129;&Ntilde;&#129;&ETH;&deg;&ETH;&acute;&ETH;&cedil;&ETH;&frac12; &lt;elcamlost@gmail.com <br/>&gt; &gt; &lt;mailto:elcamlost@gmail.com&gt;&gt; wrote: <br/>&gt; &gt; <br/>&gt; &gt; Try to look at Net::SSH::Any https://metacpan.org/pod/Net::SSH::Any <br/>&gt; &gt; &lt;https://metacpan.org/pod/Net::SSH::Any&gt; <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; On 2/14/18 5:32 AM, Lancelot Mak wrote: <br/>&gt; &gt;&gt; do u have any recommendation on module to use? what i wanted is to <br/>&gt; &gt;&gt; login ssh using username,password but in script <br/>&gt; &gt;&gt; no key, no non-interactive <br/>&gt; &gt;&gt; <br/>&gt; &gt;&gt; thanks <br/>&gt; <br/>&gt; Well, this is not an answer to your question, but because it looks like <br/>&gt; you want to use perl with ssh, you may be interested in rex - <br/>&gt; https://www.rexify.org <br/>&gt; <br/>&gt; It may just work for you as a tool, but you also can see the code if <br/>&gt; that is more important for you. <br/>&gt; Sorry if this has nothing to do with your question. <br/>&gt; <br/> <br/> <br/> <br/>-- <br/>Lancelot Mak <br/>---------------------------------------------------------------- <br/>http://facebook.com/honey.mak <br/>Used to compete <br/>Lord to complete <br/>&aring;&frac34;&#158;&aring;&#137;&#141;&egrave;&frac14;&cedil;&egrave;&acute;&#143;&aring;&#156;&uml;&aring;&iquest;&#131;&eacute;&nbsp;&shy; <br/>&aring;&brvbar;&#130;&auml;&raquo;&#138;&auml;&cedil;&#128;&aring;&#136;&#135;&aring;&#156;&uml;&auml;&cedil;&raquo;&aelig;&#137;&#139; <br/>Amen <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126792.html Tue, 20 Feb 2018 02:57:05 +0000 Re: ssh::command by Alex Mestiashvili On 02/14/2018 08:48 AM, Lancelot Mak wrote:<br/>&gt; thanks for the help.<br/>&gt; it works.<br/>&gt; <br/>&gt; On 14 February 2018 at 13:33, &#x418;&#x43B;&#x44C;&#x44F; &#x420;&#x430;&#x441;&#x441;&#x430;&#x434;&#x438;&#x43D; &lt;elcamlost@gmail.com<br/>&gt; &lt;mailto:elcamlost@gmail.com&gt;&gt; wrote:<br/>&gt; <br/>&gt; Try to look at Net::SSH::Any https://metacpan.org/pod/Net::SSH::Any<br/>&gt; &lt;https://metacpan.org/pod/Net::SSH::Any&gt;<br/>&gt; <br/>&gt; <br/>&gt; On 2/14/18 5:32 AM, Lancelot Mak wrote:<br/>&gt;&gt; do u have any recommendation on module to use? what i wanted is to<br/>&gt;&gt; login ssh using username,password but in script<br/>&gt;&gt; no key, no non-interactive<br/>&gt;&gt;<br/>&gt;&gt; thanks<br/><br/>Well, this is not an answer to your question, but because it looks like<br/>you want to use perl with ssh, you may be interested in rex -<br/>https://www.rexify.org<br/><br/>It may just work for you as a tool, but you also can see the code if<br/>that is more important for you.<br/>Sorry if this has nothing to do with your question.<br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126791.html Mon, 19 Feb 2018 14:32:13 +0000 Re: Checking if a website is up doesn't work correctly by Manfred Lotz On Thu, 15 Feb 2018 05:46:33 -0600<br/>Mike Flannigan &lt;mikeflan@att.net&gt; wrote:<br/><br/>&gt; See if some version of the attached program<br/>&gt; gives the results you expect.<br/>&gt; <br/>&gt; <br/>&gt; Mike<br/>&gt; <br/>&gt; <br/>Thanks. The attached program does better as https://notabug.org works.<br/>Only http://scripts.sil.org doesn&#39;t work. It seems there are special<br/>checks active on that site. <br/><br/>-- <br/>Manfred<br/><br/>&gt; On 2/13/2018 8:33 PM, beginners-digest-help@perl.org wrote:<br/>&gt; &gt; I tried WWW::Mechanize, and (of course) got also 403.<br/>&gt; &gt;<br/>&gt; &gt; Really strange.<br/>&gt; &gt;<br/>&gt; &gt; Is there another tool I could use for checking? I mean some tool in<br/>&gt; &gt; the Perl universe?<br/>&gt; &gt;<br/>&gt; &gt; -- Manfred <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126790.html Sat, 17 Feb 2018 17:21:40 +0000 Re: Checking if a website is up doesn't work correctly by Mike Flannigan # <br/># <br/># This scipt checks links in the html in the __DATA__ section <br/># and reports if they are good links or bad links. <br/># <br/># <br/>#!/usr/bin/perl -w <br/> <br/>use strict; <br/> <br/>use LWP::UserAgent; <br/>use HTML::LinkExtor; <br/> <br/>#-- <br/>#-- i am being very lazy in the demo <br/>#-- you should really localize it in a block <br/>#-- <br/>local $/; <br/> <br/>my $p = HTML::LinkExtor-&gt;new(\&amp;hrefs)-&gt;parse(&lt;DATA&gt;); <br/> <br/>sub hrefs{ <br/> <br/> my($tag,@links) = @_; <br/> <br/> return unless($tag =~ /^a$/i); <br/> <br/> my $p = LWP::UserAgent-&gt;new-&gt;request( <br/> HTTP::Request-&gt;new(GET =&gt; $links[1])); <br/> <br/> print $p-&gt;is_success ? &quot;GOOD: $links[1]&quot; : <br/> $p-&gt;status_line . &quot; $links[1]&quot;, &quot;\n&quot;; <br/>} <br/> <br/>__DATA__ <br/> <br/>&lt;html&gt; <br/>&lt;a href=&quot;http://scripts.sil.org/robots.txt&quot;&gt; <br/>&lt;a href=&quot;https://shlomif.github.io/&quot;&gt; <br/>&lt;a href=&quot;https://notabug.org&quot;&gt; <br/>&lt;a href=&quot;http://scripts.sil.org/OFL&quot;&gt; <br/>&lt;/html&gt; <br/> <br/> <br/> <br/> <br/> <br/>__END__ <br/> <br/> <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126789.html Thu, 15 Feb 2018 11:46:44 +0000 Re: ssh::command by Lancelot Mak thanks for the help. <br/>it works. <br/> <br/>On 14 February 2018 at 13:33, &ETH;&#152;&ETH;&raquo;&Ntilde;&#140;&Ntilde;&#143; &ETH;&nbsp;&ETH;&deg;&Ntilde;&#129;&Ntilde;&#129;&ETH;&deg;&ETH;&acute;&ETH;&cedil;&ETH;&frac12; &lt;elcamlost@gmail.com&gt; wrote: <br/> <br/>&gt; Try to look at Net::SSH::Any https://metacpan.org/pod/Net::SSH::Any <br/>&gt; <br/>&gt; <br/>&gt; On 2/14/18 5:32 AM, Lancelot Mak wrote: <br/>&gt; <br/>&gt; do u have any recommendation on module to use? what i wanted is to login <br/>&gt; ssh using username,password but in script <br/>&gt; no key, no non-interactive <br/>&gt; <br/>&gt; thanks <br/>&gt; <br/>&gt; On 13 February 2018 at 23:38, Chas. Owens &lt;chas.owens@gmail.com&gt; wrote: <br/>&gt; <br/>&gt;&gt; On Tue, Feb 13, 2018 at 1:19 AM Lancelot Mak &lt;lancelot.mak@computer.org&gt; <br/>&gt;&gt; wrote: <br/>&gt;&gt; <br/>&gt;&gt;&gt; #!/usr/bin/perl -W <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; use SSH::Command; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; $cmdln = `grep $ARGV[0] list.txt`; <br/>&gt;&gt;&gt; chomp($cmdln); <br/>&gt;&gt;&gt; ($cmdhost,$user,$pass) = split(&#39;:&#39;,$cmdln); <br/>&gt;&gt;&gt; $p = `echo $pass|base64 -d`; <br/>&gt;&gt;&gt; chomp($p); <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; $cmdlog = ssh_execute( <br/>&gt;&gt;&gt; host =&gt; $cmdhost, <br/>&gt;&gt;&gt; username =&gt; $user, <br/>&gt;&gt;&gt; <br/>&gt;&gt; password =&gt; $p,, i <br/>&gt;&gt;&gt; <br/>&gt;&gt; command =&gt; &quot;$ARGV[1]&quot;, <br/>&gt;&gt;&gt; ); <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; print $cmdlog; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; print &quot;\n&quot;; <br/>&gt;&gt;&gt; <br/>&gt;&gt; <br/>&gt;&gt; Testing on a Mac OS machine, the I found it consistently prints out 8192 <br/>&gt;&gt; characters. This should be immediately recognizable as a magic number (8k <br/>&gt;&gt; or 2**13). This tells me that SSH::Command (or the underlying libssh2 <br/>&gt;&gt; library) has an 8k buffer and once it is full, it no longer returns any <br/>&gt;&gt; data. Looking at the code for SSH::Command, I see the following <br/>&gt;&gt; function: <br/>&gt;&gt; <br/>&gt;&gt; # Execute command and get answer as text <br/>&gt;&gt; sub execute_command_and_get_answer { <br/>&gt;&gt; my ($ssh2, $command) = @_; <br/>&gt;&gt; <br/>&gt;&gt; my $chan = $ssh2-&gt;channel(); <br/>&gt;&gt; <br/>&gt;&gt; $chan-&gt;exec($command); <br/>&gt;&gt; $chan-&gt;read(my $result, 102400); <br/>&gt;&gt; chomp $result; # remove \n on string tail <br/>&gt;&gt; <br/>&gt;&gt; return $result; <br/>&gt;&gt; } <br/>&gt;&gt; <br/>&gt;&gt; This looks like a fixed read (albeit a longer one that I expected, so <br/>&gt;&gt; there is probably a fixed buffer in libssh2 too), so that is likely the <br/>&gt;&gt; problem. Changing the function to read until an end of file is detected: <br/>&gt;&gt; <br/>&gt;&gt; sub execute_command_and_get_answer { <br/>&gt;&gt; my ($ssh2, $command) = @_; <br/>&gt;&gt; <br/>&gt;&gt; my $chan = $ssh2-&gt;channel(); <br/>&gt;&gt; <br/>&gt;&gt; $chan-&gt;exec($command); <br/>&gt;&gt; <br/>&gt;&gt; my $result = &quot;&quot;; <br/>&gt;&gt; until ($chan-&gt;eof) { <br/>&gt;&gt; $chan-&gt;read(my $buf, 4_096); <br/>&gt;&gt; $result .= $buf; <br/>&gt;&gt; } <br/>&gt;&gt; chomp $result; # remove \n on string tail <br/>&gt;&gt; <br/>&gt;&gt; return $result; <br/>&gt;&gt; } <br/>&gt;&gt; <br/>&gt;&gt; seems to fix the problem. I am filling a bug against the module, but <br/>&gt;&gt; given that the last release was in 2009 and the most current version is <br/>&gt;&gt; less than 1.0 (0.7), you may want to find a different module to use. <br/>&gt;&gt; <br/>&gt;&gt; <br/>&gt;&gt; <br/>&gt; <br/>&gt; <br/>&gt; -- <br/>&gt; Lancelot Mak <br/>&gt; ---------------------------------------------------------------- <br/>&gt; http://facebook.com/honey.mak <br/>&gt; Used to compete <br/>&gt; Lord to complete <br/>&gt; &aring;&frac34;&#158;&aring;&#137;&#141;&egrave;&frac14;&cedil;&egrave;&acute;&#143;&aring;&#156;&uml;&aring;&iquest;&#131;&eacute;&nbsp;&shy; <br/>&gt; &aring;&brvbar;&#130;&auml;&raquo;&#138;&auml;&cedil;&#128;&aring;&#136;&#135;&aring;&#156;&uml;&auml;&cedil;&raquo;&aelig;&#137;&#139; <br/>&gt; Amen <br/>&gt; <br/>&gt; <br/> <br/> <br/>-- <br/>Lancelot Mak <br/>---------------------------------------------------------------- <br/>http://facebook.com/honey.mak <br/>Used to compete <br/>Lord to complete <br/>&aring;&frac34;&#158;&aring;&#137;&#141;&egrave;&frac14;&cedil;&egrave;&acute;&#143;&aring;&#156;&uml;&aring;&iquest;&#131;&eacute;&nbsp;&shy; <br/>&aring;&brvbar;&#130;&auml;&raquo;&#138;&auml;&cedil;&#128;&aring;&#136;&#135;&aring;&#156;&uml;&auml;&cedil;&raquo;&aelig;&#137;&#139; <br/>Amen <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126788.html Wed, 14 Feb 2018 07:48:36 +0000 Re: ssh::command by =?UTF-8?B?0JjQu9GM0Y8g0KDQsNGB0YHQsNC00LjQvQ==?= Try to look at Net::SSH::Any https://metacpan.org/pod/Net::SSH::Any<br/><br/><br/>On 2/14/18 5:32 AM, Lancelot Mak wrote:<br/>&gt; do u have any recommendation on module to use? what i wanted is to <br/>&gt; login ssh using username,password but in script<br/>&gt; no key, no non-interactive<br/>&gt;<br/>&gt; thanks<br/>&gt;<br/>&gt; On 13 February 2018 at 23:38, Chas. Owens &lt;chas.owens@gmail.com <br/>&gt; &lt;mailto:chas.owens@gmail.com&gt;&gt; wrote:<br/>&gt;<br/>&gt; On Tue, Feb 13, 2018 at 1:19 AM Lancelot Mak<br/>&gt; &lt;lancelot.mak@computer.org &lt;mailto:lancelot.mak@computer.org&gt;&gt; wrote:<br/>&gt;<br/>&gt; #!/usr/bin/perl -W<br/>&gt;<br/>&gt; use SSH::Command;<br/>&gt;<br/>&gt; $cmdln = `grep $ARGV[0] list.txt`;<br/>&gt; chomp($cmdln);<br/>&gt; ($cmdhost,$user,$pass) = split(&#39;:&#39;,$cmdln);<br/>&gt; $p = `echo $pass|base64 -d`;<br/>&gt; chomp($p);<br/>&gt;<br/>&gt; $cmdlog = ssh_execute(<br/>&gt; host =&gt; $cmdhost,<br/>&gt; username =&gt; $user,<br/>&gt;<br/>&gt; password =&gt; $p,, i<br/>&gt;<br/>&gt; command =&gt; &quot;$ARGV[1]&quot;,<br/>&gt; );<br/>&gt;<br/>&gt;<br/>&gt; print $cmdlog;<br/>&gt;<br/>&gt; print &quot;\n&quot;;<br/>&gt;<br/>&gt;<br/>&gt; Testing on a Mac OS machine, the I found it consistently prints<br/>&gt; out 8192 characters.&nbsp; This should be immediately recognizable as a<br/>&gt; magic number (8k or 2**13).&nbsp; This tells me that SSH::Command (or<br/>&gt; the underlying libssh2 library) has an 8k buffer and once it is<br/>&gt; full, it no longer returns any data. Looking at the code for<br/>&gt; SSH::Command, I see the following function:<br/>&gt;<br/>&gt; # Execute command and get answer as text<br/>&gt; sub execute_command_and_get_answer {<br/>&gt; &nbsp; &nbsp; my ($ssh2, $command) = @_;<br/>&gt; &nbsp; &nbsp; my $chan = $ssh2-&gt;channel();<br/>&gt; &nbsp; &nbsp; $chan-&gt;exec($command);<br/>&gt; &nbsp; &nbsp; $chan-&gt;read(my $result, 102400);<br/>&gt; &nbsp; &nbsp; chomp $result; # remove \n on string tail<br/>&gt; &nbsp; &nbsp; return $result;<br/>&gt; }<br/>&gt;<br/>&gt; This looks like a fixed read (albeit a longer one that I expected,<br/>&gt; so there is probably a fixed buffer in libssh2 too), so that is<br/>&gt; likely the problem. Changing the function to read until an end of<br/>&gt; file is detected:<br/>&gt;<br/>&gt; sub execute_command_and_get_answer {<br/>&gt; &nbsp; &nbsp; my ($ssh2, $command) = @_;<br/>&gt;<br/>&gt; &nbsp; &nbsp; my $chan = $ssh2-&gt;channel();<br/>&gt;<br/>&gt; &nbsp; &nbsp; $chan-&gt;exec($command);<br/>&gt;<br/>&gt; &nbsp; &nbsp; my $result = &quot;&quot;;<br/>&gt; &nbsp; &nbsp; until ($chan-&gt;eof) {<br/>&gt; &nbsp; &nbsp; &nbsp; &nbsp; $chan-&gt;read(my $buf, 4_096);<br/>&gt; &nbsp; &nbsp; &nbsp; &nbsp; $result .= $buf;<br/>&gt; &nbsp; &nbsp; }<br/>&gt; &nbsp; &nbsp; chomp $result; # remove \n on string tail<br/>&gt;<br/>&gt; &nbsp; &nbsp; return $result;<br/>&gt; }<br/>&gt;<br/>&gt; seems to fix the problem.&nbsp; I am filling a bug against the module,<br/>&gt; but given that the last release was in 2009 and the most current<br/>&gt; version is less than 1.0 (0.7), you may want to find a different<br/>&gt; module to use.<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; -- <br/>&gt; Lancelot Mak<br/>&gt; ----------------------------------------------------------------<br/>&gt; http://facebook.com/honey.mak<br/>&gt; Used to compete<br/>&gt; Lord to complete<br/>&gt; &#x5F9E;&#x524D;&#x8F38;&#x8D0F;&#x5728;&#x5FC3;&#x982D;<br/>&gt; &#x5982;&#x4ECA;&#x4E00;&#x5207;&#x5728;&#x4E3B;&#x624B;<br/>&gt; Amen<br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126787.html Wed, 14 Feb 2018 05:33:33 +0000 Re: ssh::command by Lancelot Mak do u have any recommendation on module to use? what i wanted is to login <br/>ssh using username,password but in script <br/>no key, no non-interactive <br/> <br/>thanks <br/> <br/>On 13 February 2018 at 23:38, Chas. Owens &lt;chas.owens@gmail.com&gt; wrote: <br/> <br/>&gt; On Tue, Feb 13, 2018 at 1:19 AM Lancelot Mak &lt;lancelot.mak@computer.org&gt; <br/>&gt; wrote: <br/>&gt; <br/>&gt;&gt; #!/usr/bin/perl -W <br/>&gt;&gt; <br/>&gt;&gt; use SSH::Command; <br/>&gt;&gt; <br/>&gt;&gt; $cmdln = `grep $ARGV[0] list.txt`; <br/>&gt;&gt; chomp($cmdln); <br/>&gt;&gt; ($cmdhost,$user,$pass) = split(&#39;:&#39;,$cmdln); <br/>&gt;&gt; $p = `echo $pass|base64 -d`; <br/>&gt;&gt; chomp($p); <br/>&gt;&gt; <br/>&gt;&gt; $cmdlog = ssh_execute( <br/>&gt;&gt; host =&gt; $cmdhost, <br/>&gt;&gt; username =&gt; $user, <br/>&gt;&gt; <br/>&gt; password =&gt; $p,, i <br/>&gt;&gt; <br/>&gt; command =&gt; &quot;$ARGV[1]&quot;, <br/>&gt;&gt; ); <br/>&gt;&gt; <br/>&gt;&gt; <br/>&gt;&gt; print $cmdlog; <br/>&gt;&gt; <br/>&gt;&gt; print &quot;\n&quot;; <br/>&gt;&gt; <br/>&gt; <br/>&gt; Testing on a Mac OS machine, the I found it consistently prints out 8192 <br/>&gt; characters. This should be immediately recognizable as a magic number (8k <br/>&gt; or 2**13). This tells me that SSH::Command (or the underlying libssh2 <br/>&gt; library) has an 8k buffer and once it is full, it no longer returns any <br/>&gt; data. Looking at the code for SSH::Command, I see the following function: <br/>&gt; <br/>&gt; # Execute command and get answer as text <br/>&gt; sub execute_command_and_get_answer { <br/>&gt; my ($ssh2, $command) = @_; <br/>&gt; <br/>&gt; my $chan = $ssh2-&gt;channel(); <br/>&gt; <br/>&gt; $chan-&gt;exec($command); <br/>&gt; $chan-&gt;read(my $result, 102400); <br/>&gt; chomp $result; # remove \n on string tail <br/>&gt; <br/>&gt; return $result; <br/>&gt; } <br/>&gt; <br/>&gt; This looks like a fixed read (albeit a longer one that I expected, so <br/>&gt; there is probably a fixed buffer in libssh2 too), so that is likely the <br/>&gt; problem. Changing the function to read until an end of file is detected: <br/>&gt; <br/>&gt; sub execute_command_and_get_answer { <br/>&gt; my ($ssh2, $command) = @_; <br/>&gt; <br/>&gt; my $chan = $ssh2-&gt;channel(); <br/>&gt; <br/>&gt; $chan-&gt;exec($command); <br/>&gt; <br/>&gt; my $result = &quot;&quot;; <br/>&gt; until ($chan-&gt;eof) { <br/>&gt; $chan-&gt;read(my $buf, 4_096); <br/>&gt; $result .= $buf; <br/>&gt; } <br/>&gt; chomp $result; # remove \n on string tail <br/>&gt; <br/>&gt; return $result; <br/>&gt; } <br/>&gt; <br/>&gt; seems to fix the problem. I am filling a bug against the module, but <br/>&gt; given that the last release was in 2009 and the most current version is <br/>&gt; less than 1.0 (0.7), you may want to find a different module to use. <br/>&gt; <br/>&gt; <br/>&gt; <br/> <br/> <br/>-- <br/>Lancelot Mak <br/>---------------------------------------------------------------- <br/>http://facebook.com/honey.mak <br/>Used to compete <br/>Lord to complete <br/>&aring;&frac34;&#158;&aring;&#137;&#141;&egrave;&frac14;&cedil;&egrave;&acute;&#143;&aring;&#156;&uml;&aring;&iquest;&#131;&eacute;&nbsp;&shy; <br/>&aring;&brvbar;&#130;&auml;&raquo;&#138;&auml;&cedil;&#128;&aring;&#136;&#135;&aring;&#156;&uml;&auml;&cedil;&raquo;&aelig;&#137;&#139; <br/>Amen <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126786.html Wed, 14 Feb 2018 02:33:04 +0000 Re: Checking if a website is up doesn't work correctly by Andy Bach &gt; Is there another tool I could use for checking? I mean some tool in the <br/>Perl universe? <br/> <br/>Well, lwp-dump is a perl util - comes w/ LWP I believe. The sil.org, for <br/>one, just returns forbidden/403 for their own policy reasons, but as far as <br/>your &quot;is it up?&quot; question, that should be answer enough. It uses <br/>LWP::UserAgent. To play fair (though it doesn&#39;t help with sil.org) you <br/>should be looking for /robots.txt as you&#39;re creating a robot. <br/> <br/>Pretty sure there&#39;s a libcurl interface (Net::Curl and WWW::Curl for two) <br/>which might have better luck impersonating a proper user to get around the <br/>policy. But your urls so far have shown some odd repsonse using wget so <br/>you may want to check them out first before your script has at them. <br/> <br/>On Tue, Feb 13, 2018 at 2:34 PM, Manfred Lotz &lt;ml_news@posteo.de&gt; wrote: <br/> <br/>&gt; On Tue, 13 Feb 2018 13:50:55 -0600 <br/>&gt; Andy Bach &lt;afbach@gmail.com&gt; wrote: <br/>&gt; <br/>&gt; &gt; $ wget http://scripts.sil.org/OFL <br/>&gt; &gt; --2018-02-13 13:42:50-- http://scripts.sil.org/OFL <br/>&gt; &gt; Resolving scripts.sil.org (scripts.sil.org)... 209.12.63.143 <br/>&gt; &gt; Connecting to scripts.sil.org (scripts.sil.org)|209.12.63.143|:80... <br/>&gt; &gt; connected. <br/>&gt; &gt; HTTP request sent, awaiting response... 302 Found <br/>&gt; &gt; Location: <br/>&gt; &gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>&gt; &gt; [following] --2018-02-13 13:42:52-- <br/>&gt; &gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>&gt; &gt; Reusing existing connection to scripts.sil.org:80. <br/>&gt; &gt; HTTP request sent, awaiting response... 302 Moved Temporarily <br/>&gt; &gt; Location: /cms/scripts/page.php?site_id=nrsi&amp;id=OFL&amp;_sc=1 [following] <br/>&gt; &gt; --2018-02-13 13:42:52-- <br/>&gt; &gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL&amp;_sc=1 <br/>&gt; &gt; Reusing existing connection to scripts.sil.org:80. <br/>&gt; &gt; HTTP request sent, awaiting response... 302 Moved Temporarily <br/>&gt; &gt; Location: /cms/scripts/page.php?site_id=nrsi&amp;id=OFL [following] <br/>&gt; &gt; --2018-02-13 13:42:53-- <br/>&gt; &gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>&gt; &gt; Reusing existing connection to scripts.sil.org:80. <br/>&gt; &gt; HTTP request sent, awaiting response... 200 OK <br/>&gt; &gt; Length: unspecified [text/html] <br/>&gt; &gt; Saving to: &acirc;&#128;&#152;OFL&acirc;&#128;&#153; <br/>&gt; &gt; <br/>&gt; &gt; [ <br/>&gt; &gt; &lt;=&gt; <br/>&gt; &gt; ] 37,439 59.6KB/s in 0.6s <br/>&gt; &gt; <br/>&gt; &gt; 2018-02-13 13:42:55 (59.6 KB/s) - &acirc;&#128;&#152;OFL&acirc;&#128;&#153; saved [37439] <br/>&gt; &gt; <br/>&gt; &gt; so it may not be following the 302s. I&#39;m not sure you&#39;re using the <br/>&gt; &gt; correct tool here. A little more straight forward <br/>&gt; &gt; <br/>&gt; &gt; andy@wiwmb-md-afb-mint:~/spam$ wget http://scripts.sil.org/robots.txt <br/>&gt; &gt; --2018-02-13 13:47:27-- http://scripts.sil.org/robots.txt <br/>&gt; &gt; Resolving scripts.sil.org (scripts.sil.org)... 209.12.63.143 <br/>&gt; &gt; Connecting to scripts.sil.org (scripts.sil.org)|209.12.63.143|:80... <br/>&gt; &gt; connected. <br/>&gt; &gt; HTTP request sent, awaiting response... 200 OK <br/>&gt; &gt; Length: 36 [text/plain] <br/>&gt; &gt; Saving to: &acirc;&#128;&#152;robots.txt&acirc;&#128;&#153; <br/>&gt; &gt; <br/>&gt; &gt; 100%[======================================================= <br/>&gt; =================================&gt;] <br/>&gt; &gt; 36 --.-K/s in 0s <br/>&gt; &gt; <br/>&gt; &gt; 2018-02-13 13:47:27 (2.99 MB/s) - &acirc;&#128;&#152;robots.txt&acirc;&#128;&#153; saved [36/36] <br/>&gt; &gt; <br/>&gt; &gt; but <br/>&gt; &gt; $ is_it_up.pl <br/>&gt; &gt; http://scripts.sil.org/robots.txt is DOWN!!!! <br/>&gt; &gt; <br/>&gt; &gt; You might look at more LWP tools: <br/>&gt; &gt; $ lwp-dump https://www.sil.org <br/>&gt; &gt; HTTP/1.1 403 Forbidden <br/>&gt; &gt; Cache-Control: max-age=10 <br/>&gt; &gt; Connection: keep-alive <br/>&gt; &gt; Date: Tue, 13 Feb 2018 19:49:47 GMT <br/>&gt; &gt; Server: cloudflare <br/>&gt; &gt; Content-Type: text/html; charset=UTF-8 <br/>&gt; &gt; Expires: Tue, 13 Feb 2018 19:49:57 GMT <br/>&gt; &gt; CF-RAY: 3eca501a5d569895-LAX <br/>&gt; &gt; Expect-CT: max-age=604800, report-uri=&quot; <br/>&gt; &gt; https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct&quot; <br/>&gt; &gt; Set-Cookie: __cfduid=dd8038f4f2c995fa4b4c7fa8beb2b42f31518551387; <br/>&gt; &gt; expires=Wed, 13-Feb-19 19:49:47 GMT; path=/; domain=.sil.org; HttpOnly <br/>&gt; &gt; X-Frame-Options: SAMEORIGIN <br/>&gt; &gt; <br/>&gt; &gt; &lt;!DOCTYPE html&gt; <br/>&gt; &gt; &lt;!--[if lt IE 7]&gt; &lt;html class=&quot;no-js ie6 oldie&quot; lang=&quot;en-US&quot;&gt; <br/>&gt; &gt; &lt;![endif]--&gt; &lt;!--[if IE 7]&gt; &lt;html class=&quot;no-js ie7 oldie&quot; <br/>&gt; &gt; lang=&quot;en-US&quot;&gt; &lt;![endif]--&gt; &lt;!--[if IE 8]&gt; &lt;html class=&quot;no-js ie8 <br/>&gt; &gt; oldie&quot; lang=&quot;en-US&quot;&gt; &lt;![endif]--&gt; &lt;!--[if gt IE 8]&gt;&lt;!--&gt; &lt;html <br/>&gt; &gt; class=&quot;no-js&quot; lang=&quot;en-US&quot;&gt; &lt;!--&lt;![endif]--&gt; &lt;head&gt; <br/>&gt; &gt; &lt;title&gt;Access denied | www.sil.org used Cloudflare to restrict <br/>&gt; &gt; access&lt;/title&gt; <br/>&gt; &gt; &lt;meta charset=&quot;UTF-8&quot; /&gt; <br/>&gt; &gt; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt; <br/>&gt; &gt; &lt;meta http-equiv=... <br/>&gt; &gt; (+ 2770 more bytes not shown) <br/>&gt; &gt; <br/>&gt; &gt; so it&#39;s up, but &quot;forbidden&quot; probably as the user agent isn&#39;t set or <br/>&gt; &gt; some other policy reason. <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; <br/>&gt; I tried WWW::Mechanize, and (of course) got also 403. <br/>&gt; <br/>&gt; Really strange. <br/>&gt; <br/>&gt; Is there another tool I could use for checking? I mean some tool in the <br/>&gt; Perl universe? <br/>&gt; <br/>&gt; -- <br/>&gt; Manfred <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; &gt; On Tue, Feb 13, 2018 at 11:33 AM, Manfred Lotz &lt;ml_news@posteo.de&gt; <br/>&gt; &gt; wrote: <br/>&gt; &gt; <br/>&gt; &gt; &gt; On Tue, 13 Feb 2018 10:47:42 -0600 <br/>&gt; &gt; &gt; Andy Bach &lt;afbach@gmail.com&gt; wrote: <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; The site doesn&#39;t like &#39;head&#39; requests? get works <br/>&gt; &gt; &gt; &gt; #!/usr/bin/perl <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; use strict; <br/>&gt; &gt; &gt; &gt; use warnings; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; use LWP::Simple; <br/>&gt; &gt; &gt; &gt; # my $url=&quot;https://shlomif.github.io/&quot;; <br/>&gt; &gt; &gt; &gt; my $url=&quot;http://www.notabug.org/&quot;; <br/>&gt; &gt; &gt; &gt; print &quot;$url is &quot;, ( <br/>&gt; &gt; &gt; &gt; (! get($url)) ? &quot;DOWN!!!!&quot; <br/>&gt; &gt; &gt; &gt; : &quot;up&quot; <br/>&gt; &gt; &gt; &gt; ), &quot;\n&quot;; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; $ is_it_up.pl <br/>&gt; &gt; &gt; &gt; http://www.notabug.org/ is up <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; You are right. <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; But am afraid this is not all of it. If I test <br/>&gt; &gt; &gt; http://scripts.sil.org/OFL then I get an error but it is fine in <br/>&gt; &gt; &gt; firefox. <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; Very strange. <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; -- <br/>&gt; &gt; &gt; Manfred <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; On Tue, Feb 13, 2018 at 5:25 AM, Manfred Lotz &lt;ml_news@posteo.de&gt; <br/>&gt; &gt; &gt; &gt; wrote: <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; Hi there, <br/>&gt; &gt; &gt; &gt; &gt; Somewhere I found an example how to check if a website is up. <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; Here my sample: <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; #! /usr/bin/perl <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; use strict; <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; use LWP::Simple; <br/>&gt; &gt; &gt; &gt; &gt; my $url=&quot;https://notabug.org&quot;; <br/>&gt; &gt; &gt; &gt; &gt; if (! head($url)) { <br/>&gt; &gt; &gt; &gt; &gt; die &quot;$url is DOWN!!!!&quot; <br/>&gt; &gt; &gt; &gt; &gt; } <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; Running above code I get <br/>&gt; &gt; &gt; &gt; &gt; https://notabug.org is DOWN!!!! at ./check_url.pl line 8. <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; However, firefox shows the site works ok. <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; What am I doing wrong? <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; -- <br/>&gt; &gt; &gt; &gt; &gt; Thanks, <br/>&gt; &gt; &gt; &gt; &gt; Manfred <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; -- <br/>&gt; &gt; &gt; &gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/>&gt; &gt; &gt; &gt; &gt; For additional commands, e-mail: beginners-help@perl.org <br/>&gt; &gt; &gt; &gt; &gt; http://learn.perl.org/ <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; -- <br/>&gt; &gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/>&gt; &gt; &gt; For additional commands, e-mail: beginners-help@perl.org <br/>&gt; &gt; &gt; http://learn.perl.org/ <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; <br/>&gt; -- <br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/>&gt; For additional commands, e-mail: beginners-help@perl.org <br/>&gt; http://learn.perl.org/ <br/>&gt; <br/>&gt; <br/>&gt; <br/> <br/> <br/>-- <br/> <br/>a <br/> <br/>Andy Bach, <br/>afbach@gmail.com <br/>608 658-1890 cell <br/>608 261-5738 wk <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126785.html Tue, 13 Feb 2018 21:21:57 +0000 Re: Checking if a website is up doesn't work correctly by Manfred Lotz On Tue, 13 Feb 2018 13:50:55 -0600 <br/>Andy Bach &lt;afbach@gmail.com&gt; wrote: <br/> <br/>&gt; $ wget http://scripts.sil.org/OFL <br/>&gt; --2018-02-13 13:42:50-- http://scripts.sil.org/OFL <br/>&gt; Resolving scripts.sil.org (scripts.sil.org)... 209.12.63.143 <br/>&gt; Connecting to scripts.sil.org (scripts.sil.org)|209.12.63.143|:80... <br/>&gt; connected. <br/>&gt; HTTP request sent, awaiting response... 302 Found <br/>&gt; Location: <br/>&gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>&gt; [following] --2018-02-13 13:42:52-- <br/>&gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>&gt; Reusing existing connection to scripts.sil.org:80. <br/>&gt; HTTP request sent, awaiting response... 302 Moved Temporarily <br/>&gt; Location: /cms/scripts/page.php?site_id=nrsi&amp;id=OFL&amp;_sc=1 [following] <br/>&gt; --2018-02-13 13:42:52-- <br/>&gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL&amp;_sc=1 <br/>&gt; Reusing existing connection to scripts.sil.org:80. <br/>&gt; HTTP request sent, awaiting response... 302 Moved Temporarily <br/>&gt; Location: /cms/scripts/page.php?site_id=nrsi&amp;id=OFL [following] <br/>&gt; --2018-02-13 13:42:53-- <br/>&gt; http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>&gt; Reusing existing connection to scripts.sil.org:80. <br/>&gt; HTTP request sent, awaiting response... 200 OK <br/>&gt; Length: unspecified [text/html] <br/>&gt; Saving to: &lsquo;OFL&rsquo; <br/>&gt; <br/>&gt; [ <br/>&gt; &lt;=&gt; <br/>&gt; ] 37,439 59.6KB/s in 0.6s <br/>&gt; <br/>&gt; 2018-02-13 13:42:55 (59.6 KB/s) - &lsquo;OFL&rsquo; saved [37439] <br/>&gt; <br/>&gt; so it may not be following the 302s. I&#39;m not sure you&#39;re using the <br/>&gt; correct tool here. A little more straight forward <br/>&gt; <br/>&gt; andy@wiwmb-md-afb-mint:~/spam$ wget http://scripts.sil.org/robots.txt <br/>&gt; --2018-02-13 13:47:27-- http://scripts.sil.org/robots.txt <br/>&gt; Resolving scripts.sil.org (scripts.sil.org)... 209.12.63.143 <br/>&gt; Connecting to scripts.sil.org (scripts.sil.org)|209.12.63.143|:80... <br/>&gt; connected. <br/>&gt; HTTP request sent, awaiting response... 200 OK <br/>&gt; Length: 36 [text/plain] <br/>&gt; Saving to: &lsquo;robots.txt&rsquo; <br/>&gt; <br/>&gt; 100%[========================================================================================&gt;] <br/>&gt; 36 --.-K/s in 0s <br/>&gt; <br/>&gt; 2018-02-13 13:47:27 (2.99 MB/s) - &lsquo;robots.txt&rsquo; saved [36/36] <br/>&gt; <br/>&gt; but <br/>&gt; $ is_it_up.pl <br/>&gt; http://scripts.sil.org/robots.txt is DOWN!!!! <br/>&gt; <br/>&gt; You might look at more LWP tools: <br/>&gt; $ lwp-dump https://www.sil.org <br/>&gt; HTTP/1.1 403 Forbidden <br/>&gt; Cache-Control: max-age=10 <br/>&gt; Connection: keep-alive <br/>&gt; Date: Tue, 13 Feb 2018 19:49:47 GMT <br/>&gt; Server: cloudflare <br/>&gt; Content-Type: text/html; charset=UTF-8 <br/>&gt; Expires: Tue, 13 Feb 2018 19:49:57 GMT <br/>&gt; CF-RAY: 3eca501a5d569895-LAX <br/>&gt; Expect-CT: max-age=604800, report-uri=&quot; <br/>&gt; https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct&quot; <br/>&gt; Set-Cookie: __cfduid=dd8038f4f2c995fa4b4c7fa8beb2b42f31518551387; <br/>&gt; expires=Wed, 13-Feb-19 19:49:47 GMT; path=/; domain=.sil.org; HttpOnly <br/>&gt; X-Frame-Options: SAMEORIGIN <br/>&gt; <br/>&gt; &lt;!DOCTYPE html&gt; <br/>&gt; &lt;!--[if lt IE 7]&gt; &lt;html class=&quot;no-js ie6 oldie&quot; lang=&quot;en-US&quot;&gt; <br/>&gt; &lt;![endif]--&gt; &lt;!--[if IE 7]&gt; &lt;html class=&quot;no-js ie7 oldie&quot; <br/>&gt; lang=&quot;en-US&quot;&gt; &lt;![endif]--&gt; &lt;!--[if IE 8]&gt; &lt;html class=&quot;no-js ie8 <br/>&gt; oldie&quot; lang=&quot;en-US&quot;&gt; &lt;![endif]--&gt; &lt;!--[if gt IE 8]&gt;&lt;!--&gt; &lt;html <br/>&gt; class=&quot;no-js&quot; lang=&quot;en-US&quot;&gt; &lt;!--&lt;![endif]--&gt; &lt;head&gt; <br/>&gt; &lt;title&gt;Access denied | www.sil.org used Cloudflare to restrict <br/>&gt; access&lt;/title&gt; <br/>&gt; &lt;meta charset=&quot;UTF-8&quot; /&gt; <br/>&gt; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt; <br/>&gt; &lt;meta http-equiv=... <br/>&gt; (+ 2770 more bytes not shown) <br/>&gt; <br/>&gt; so it&#39;s up, but &quot;forbidden&quot; probably as the user agent isn&#39;t set or <br/>&gt; some other policy reason. <br/>&gt; <br/>&gt; <br/> <br/>I tried WWW::Mechanize, and (of course) got also 403. <br/> <br/>Really strange. <br/> <br/>Is there another tool I could use for checking? I mean some tool in the <br/>Perl universe? <br/> <br/>-- <br/>Manfred <br/> <br/> <br/> <br/>&gt; On Tue, Feb 13, 2018 at 11:33 AM, Manfred Lotz &lt;ml_news@posteo.de&gt; <br/>&gt; wrote: <br/>&gt; <br/>&gt; &gt; On Tue, 13 Feb 2018 10:47:42 -0600 <br/>&gt; &gt; Andy Bach &lt;afbach@gmail.com&gt; wrote: <br/>&gt; &gt; <br/>&gt; &gt; &gt; The site doesn&#39;t like &#39;head&#39; requests? get works <br/>&gt; &gt; &gt; #!/usr/bin/perl <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; use strict; <br/>&gt; &gt; &gt; use warnings; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; use LWP::Simple; <br/>&gt; &gt; &gt; # my $url=&quot;https://shlomif.github.io/&quot;; <br/>&gt; &gt; &gt; my $url=&quot;http://www.notabug.org/&quot;; <br/>&gt; &gt; &gt; print &quot;$url is &quot;, ( <br/>&gt; &gt; &gt; (! get($url)) ? &quot;DOWN!!!!&quot; <br/>&gt; &gt; &gt; : &quot;up&quot; <br/>&gt; &gt; &gt; ), &quot;\n&quot;; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; $ is_it_up.pl <br/>&gt; &gt; &gt; http://www.notabug.org/ is up <br/>&gt; &gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; You are right. <br/>&gt; &gt; <br/>&gt; &gt; But am afraid this is not all of it. If I test <br/>&gt; &gt; http://scripts.sil.org/OFL then I get an error but it is fine in <br/>&gt; &gt; firefox. <br/>&gt; &gt; <br/>&gt; &gt; Very strange. <br/>&gt; &gt; <br/>&gt; &gt; -- <br/>&gt; &gt; Manfred <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; On Tue, Feb 13, 2018 at 5:25 AM, Manfred Lotz &lt;ml_news@posteo.de&gt; <br/>&gt; &gt; &gt; wrote: <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; Hi there, <br/>&gt; &gt; &gt; &gt; Somewhere I found an example how to check if a website is up. <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; Here my sample: <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; #! /usr/bin/perl <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; use strict; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; use LWP::Simple; <br/>&gt; &gt; &gt; &gt; my $url=&quot;https://notabug.org&quot;; <br/>&gt; &gt; &gt; &gt; if (! head($url)) { <br/>&gt; &gt; &gt; &gt; die &quot;$url is DOWN!!!!&quot; <br/>&gt; &gt; &gt; &gt; } <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; Running above code I get <br/>&gt; &gt; &gt; &gt; https://notabug.org is DOWN!!!! at ./check_url.pl line 8. <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; However, firefox shows the site works ok. <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; What am I doing wrong? <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; -- <br/>&gt; &gt; &gt; &gt; Thanks, <br/>&gt; &gt; &gt; &gt; Manfred <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; -- <br/>&gt; &gt; &gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/>&gt; &gt; &gt; &gt; For additional commands, e-mail: beginners-help@perl.org <br/>&gt; &gt; &gt; &gt; http://learn.perl.org/ <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; -- <br/>&gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/>&gt; &gt; For additional commands, e-mail: beginners-help@perl.org <br/>&gt; &gt; http://learn.perl.org/ <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; <br/>&gt; <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126784.html Tue, 13 Feb 2018 20:34:26 +0000 Re: Checking if a website is up doesn't work correctly by Andy Bach $ wget http://scripts.sil.org/OFL <br/>--2018-02-13 13:42:50-- http://scripts.sil.org/OFL <br/>Resolving scripts.sil.org (scripts.sil.org)... 209.12.63.143 <br/>Connecting to scripts.sil.org (scripts.sil.org)|209.12.63.143|:80... <br/>connected. <br/>HTTP request sent, awaiting response... 302 Found <br/>Location: http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>[following] <br/>--2018-02-13 13:42:52-- <br/>http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>Reusing existing connection to scripts.sil.org:80. <br/>HTTP request sent, awaiting response... 302 Moved Temporarily <br/>Location: /cms/scripts/page.php?site_id=nrsi&amp;id=OFL&amp;_sc=1 [following] <br/>--2018-02-13 13:42:52-- <br/>http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL&amp;_sc=1 <br/>Reusing existing connection to scripts.sil.org:80. <br/>HTTP request sent, awaiting response... 302 Moved Temporarily <br/>Location: /cms/scripts/page.php?site_id=nrsi&amp;id=OFL [following] <br/>--2018-02-13 13:42:53-- <br/>http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=OFL <br/>Reusing existing connection to scripts.sil.org:80. <br/>HTTP request sent, awaiting response... 200 OK <br/>Length: unspecified [text/html] <br/>Saving to: &acirc;&#128;&#152;OFL&acirc;&#128;&#153; <br/> <br/> [ <br/>&lt;=&gt; <br/>] 37,439 59.6KB/s in 0.6s <br/> <br/>2018-02-13 13:42:55 (59.6 KB/s) - &acirc;&#128;&#152;OFL&acirc;&#128;&#153; saved [37439] <br/> <br/>so it may not be following the 302s. I&#39;m not sure you&#39;re using the correct <br/>tool here. A little more straight forward <br/> <br/>andy@wiwmb-md-afb-mint:~/spam$ wget http://scripts.sil.org/robots.txt <br/>--2018-02-13 13:47:27-- http://scripts.sil.org/robots.txt <br/>Resolving scripts.sil.org (scripts.sil.org)... 209.12.63.143 <br/>Connecting to scripts.sil.org (scripts.sil.org)|209.12.63.143|:80... <br/>connected. <br/>HTTP request sent, awaiting response... 200 OK <br/>Length: 36 [text/plain] <br/>Saving to: &acirc;&#128;&#152;robots.txt&acirc;&#128;&#153; <br/> <br/>100%[========================================================================================&gt;] <br/>36 --.-K/s in 0s <br/> <br/>2018-02-13 13:47:27 (2.99 MB/s) - &acirc;&#128;&#152;robots.txt&acirc;&#128;&#153; saved [36/36] <br/> <br/>but <br/>$ is_it_up.pl <br/>http://scripts.sil.org/robots.txt is DOWN!!!! <br/> <br/>You might look at more LWP tools: <br/>$ lwp-dump https://www.sil.org <br/>HTTP/1.1 403 Forbidden <br/>Cache-Control: max-age=10 <br/>Connection: keep-alive <br/>Date: Tue, 13 Feb 2018 19:49:47 GMT <br/>Server: cloudflare <br/>Content-Type: text/html; charset=UTF-8 <br/>Expires: Tue, 13 Feb 2018 19:49:57 GMT <br/>CF-RAY: 3eca501a5d569895-LAX <br/>Expect-CT: max-age=604800, report-uri=&quot; <br/>https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct&quot; <br/>Set-Cookie: __cfduid=dd8038f4f2c995fa4b4c7fa8beb2b42f31518551387; <br/>expires=Wed, 13-Feb-19 19:49:47 GMT; path=/; domain=.sil.org; HttpOnly <br/>X-Frame-Options: SAMEORIGIN <br/> <br/>&lt;!DOCTYPE html&gt; <br/>&lt;!--[if lt IE 7]&gt; &lt;html class=&quot;no-js ie6 oldie&quot; lang=&quot;en-US&quot;&gt; &lt;![endif]--&gt; <br/>&lt;!--[if IE 7]&gt; &lt;html class=&quot;no-js ie7 oldie&quot; lang=&quot;en-US&quot;&gt; &lt;![endif]--&gt; <br/>&lt;!--[if IE 8]&gt; &lt;html class=&quot;no-js ie8 oldie&quot; lang=&quot;en-US&quot;&gt; &lt;![endif]--&gt; <br/>&lt;!--[if gt IE 8]&gt;&lt;!--&gt; &lt;html class=&quot;no-js&quot; lang=&quot;en-US&quot;&gt; &lt;!--&lt;![endif]--&gt; <br/>&lt;head&gt; <br/>&lt;title&gt;Access denied | www.sil.org used Cloudflare to restrict <br/>access&lt;/title&gt; <br/>&lt;meta charset=&quot;UTF-8&quot; /&gt; <br/>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt; <br/>&lt;meta http-equiv=... <br/>(+ 2770 more bytes not shown) <br/> <br/>so it&#39;s up, but &quot;forbidden&quot; probably as the user agent isn&#39;t set or some <br/>other policy reason. <br/> <br/> <br/>On Tue, Feb 13, 2018 at 11:33 AM, Manfred Lotz &lt;ml_news@posteo.de&gt; wrote: <br/> <br/>&gt; On Tue, 13 Feb 2018 10:47:42 -0600 <br/>&gt; Andy Bach &lt;afbach@gmail.com&gt; wrote: <br/>&gt; <br/>&gt; &gt; The site doesn&#39;t like &#39;head&#39; requests? get works <br/>&gt; &gt; #!/usr/bin/perl <br/>&gt; &gt; <br/>&gt; &gt; use strict; <br/>&gt; &gt; use warnings; <br/>&gt; &gt; <br/>&gt; &gt; use LWP::Simple; <br/>&gt; &gt; # my $url=&quot;https://shlomif.github.io/&quot;; <br/>&gt; &gt; my $url=&quot;http://www.notabug.org/&quot;; <br/>&gt; &gt; print &quot;$url is &quot;, ( <br/>&gt; &gt; (! get($url)) ? &quot;DOWN!!!!&quot; <br/>&gt; &gt; : &quot;up&quot; <br/>&gt; &gt; ), &quot;\n&quot;; <br/>&gt; &gt; <br/>&gt; &gt; $ is_it_up.pl <br/>&gt; &gt; http://www.notabug.org/ is up <br/>&gt; &gt; <br/>&gt; <br/>&gt; You are right. <br/>&gt; <br/>&gt; But am afraid this is not all of it. If I test <br/>&gt; http://scripts.sil.org/OFL then I get an error but it is fine in <br/>&gt; firefox. <br/>&gt; <br/>&gt; Very strange. <br/>&gt; <br/>&gt; -- <br/>&gt; Manfred <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; &gt; <br/>&gt; &gt; On Tue, Feb 13, 2018 at 5:25 AM, Manfred Lotz &lt;ml_news@posteo.de&gt; <br/>&gt; &gt; wrote: <br/>&gt; &gt; <br/>&gt; &gt; &gt; Hi there, <br/>&gt; &gt; &gt; Somewhere I found an example how to check if a website is up. <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; Here my sample: <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; #! /usr/bin/perl <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; use strict; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; use LWP::Simple; <br/>&gt; &gt; &gt; my $url=&quot;https://notabug.org&quot;; <br/>&gt; &gt; &gt; if (! head($url)) { <br/>&gt; &gt; &gt; die &quot;$url is DOWN!!!!&quot; <br/>&gt; &gt; &gt; } <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; Running above code I get <br/>&gt; &gt; &gt; https://notabug.org is DOWN!!!! at ./check_url.pl line 8. <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; However, firefox shows the site works ok. <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; What am I doing wrong? <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; -- <br/>&gt; &gt; &gt; Thanks, <br/>&gt; &gt; &gt; Manfred <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; -- <br/>&gt; &gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/>&gt; &gt; &gt; For additional commands, e-mail: beginners-help@perl.org <br/>&gt; &gt; &gt; http://learn.perl.org/ <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; &gt; <br/>&gt; &gt; <br/>&gt; &gt; <br/>&gt; <br/>&gt; -- <br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/>&gt; For additional commands, e-mail: beginners-help@perl.org <br/>&gt; http://learn.perl.org/ <br/>&gt; <br/>&gt; <br/>&gt; <br/> <br/> <br/>-- <br/> <br/>a <br/> <br/>Andy Bach, <br/>afbach@gmail.com <br/>608 658-1890 cell <br/>608 261-5738 wk <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126783.html Tue, 13 Feb 2018 19:51:04 +0000 Re: Checking if a website is up doesn't work correctly by Manfred Lotz On Tue, 13 Feb 2018 10:47:42 -0600<br/>Andy Bach &lt;afbach@gmail.com&gt; wrote:<br/><br/>&gt; The site doesn&#39;t like &#39;head&#39; requests? get works<br/>&gt; #!/usr/bin/perl<br/>&gt; <br/>&gt; use strict;<br/>&gt; use warnings;<br/>&gt; <br/>&gt; use LWP::Simple;<br/>&gt; # my $url=&quot;https://shlomif.github.io/&quot;;<br/>&gt; my $url=&quot;http://www.notabug.org/&quot;;<br/>&gt; print &quot;$url is &quot;, (<br/>&gt; (! get($url)) ? &quot;DOWN!!!!&quot;<br/>&gt; : &quot;up&quot;<br/>&gt; ), &quot;\n&quot;;<br/>&gt; <br/>&gt; $ is_it_up.pl<br/>&gt; http://www.notabug.org/ is up<br/>&gt; <br/><br/>You are right. <br/><br/>But am afraid this is not all of it. If I test<br/>http://scripts.sil.org/OFL then I get an error but it is fine in<br/>firefox.<br/><br/>Very strange.<br/><br/>-- <br/>Manfred<br/><br/><br/><br/>&gt; <br/>&gt; On Tue, Feb 13, 2018 at 5:25 AM, Manfred Lotz &lt;ml_news@posteo.de&gt;<br/>&gt; wrote:<br/>&gt; <br/>&gt; &gt; Hi there,<br/>&gt; &gt; Somewhere I found an example how to check if a website is up.<br/>&gt; &gt;<br/>&gt; &gt; Here my sample:<br/>&gt; &gt;<br/>&gt; &gt; #! /usr/bin/perl<br/>&gt; &gt;<br/>&gt; &gt; use strict;<br/>&gt; &gt;<br/>&gt; &gt; use LWP::Simple;<br/>&gt; &gt; my $url=&quot;https://notabug.org&quot;;<br/>&gt; &gt; if (! head($url)) {<br/>&gt; &gt; die &quot;$url is DOWN!!!!&quot;<br/>&gt; &gt; }<br/>&gt; &gt;<br/>&gt; &gt; Running above code I get<br/>&gt; &gt; https://notabug.org is DOWN!!!! at ./check_url.pl line 8.<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt; However, firefox shows the site works ok.<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt; What am I doing wrong?<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt; --<br/>&gt; &gt; Thanks,<br/>&gt; &gt; Manfred<br/>&gt; &gt;<br/>&gt; &gt; --<br/>&gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; &gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; &gt; http://learn.perl.org/<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt; <br/>&gt; <br/>&gt; <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126782.html Tue, 13 Feb 2018 17:33:27 +0000 Re: Checking if a website is up doesn't work correctly by Andy Bach The site doesn&#39;t like &#39;head&#39; requests? get works<br/>#!/usr/bin/perl<br/><br/>use strict;<br/>use warnings;<br/><br/>use LWP::Simple;<br/># my $url=&quot;https://shlomif.github.io/&quot;;<br/>my $url=&quot;http://www.notabug.org/&quot;;<br/>print &quot;$url is &quot;, (<br/> (! get($url)) ? &quot;DOWN!!!!&quot;<br/> : &quot;up&quot;<br/> ), &quot;\n&quot;;<br/><br/>$ is_it_up.pl<br/>http://www.notabug.org/ is up<br/><br/><br/>On Tue, Feb 13, 2018 at 5:25 AM, Manfred Lotz &lt;ml_news@posteo.de&gt; wrote:<br/><br/>&gt; Hi there,<br/>&gt; Somewhere I found an example how to check if a website is up.<br/>&gt;<br/>&gt; Here my sample:<br/>&gt;<br/>&gt; #! /usr/bin/perl<br/>&gt;<br/>&gt; use strict;<br/>&gt;<br/>&gt; use LWP::Simple;<br/>&gt; my $url=&quot;https://notabug.org&quot;;<br/>&gt; if (! head($url)) {<br/>&gt; die &quot;$url is DOWN!!!!&quot;<br/>&gt; }<br/>&gt;<br/>&gt; Running above code I get<br/>&gt; https://notabug.org is DOWN!!!! at ./check_url.pl line 8.<br/>&gt;<br/>&gt;<br/>&gt; However, firefox shows the site works ok.<br/>&gt;<br/>&gt;<br/>&gt; What am I doing wrong?<br/>&gt;<br/>&gt;<br/>&gt; --<br/>&gt; Thanks,<br/>&gt; Manfred<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/><br/>-- <br/><br/>a<br/><br/>Andy Bach,<br/>afbach@gmail.com<br/>608 658-1890 cell<br/>608 261-5738 wk<br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126781.html Tue, 13 Feb 2018 16:47:48 +0000 Re: ssh::command by Chas. Owens On Tue, Feb 13, 2018 at 1:19 AM Lancelot Mak &lt;lancelot.mak@computer.org&gt;<br/>wrote:<br/><br/>&gt; #!/usr/bin/perl -W<br/>&gt;<br/>&gt; use SSH::Command;<br/>&gt;<br/>&gt; $cmdln = `grep $ARGV[0] list.txt`;<br/>&gt; chomp($cmdln);<br/>&gt; ($cmdhost,$user,$pass) = split(&#39;:&#39;,$cmdln);<br/>&gt; $p = `echo $pass|base64 -d`;<br/>&gt; chomp($p);<br/>&gt;<br/>&gt; $cmdlog = ssh_execute(<br/>&gt; host =&gt; $cmdhost,<br/>&gt; username =&gt; $user,<br/>&gt;<br/>password =&gt; $p,, i<br/>&gt;<br/>command =&gt; &quot;$ARGV[1]&quot;,<br/>&gt; );<br/>&gt;<br/>&gt;<br/>&gt; print $cmdlog;<br/>&gt;<br/>&gt; print &quot;\n&quot;;<br/>&gt;<br/><br/>Testing on a Mac OS machine, the I found it consistently prints out 8192<br/>characters. This should be immediately recognizable as a magic number (8k<br/>or 2**13). This tells me that SSH::Command (or the underlying libssh2<br/>library) has an 8k buffer and once it is full, it no longer returns any<br/>data. Looking at the code for SSH::Command, I see the following function:<br/><br/># Execute command and get answer as text<br/>sub execute_command_and_get_answer {<br/> my ($ssh2, $command) = @_;<br/><br/> my $chan = $ssh2-&gt;channel();<br/><br/> $chan-&gt;exec($command);<br/> $chan-&gt;read(my $result, 102400);<br/> chomp $result; # remove \n on string tail<br/><br/> return $result;<br/>}<br/><br/>This looks like a fixed read (albeit a longer one that I expected, so there<br/>is probably a fixed buffer in libssh2 too), so that is likely the problem.<br/>Changing the function to read until an end of file is detected:<br/><br/>sub execute_command_and_get_answer {<br/> my ($ssh2, $command) = @_;<br/><br/> my $chan = $ssh2-&gt;channel();<br/><br/> $chan-&gt;exec($command);<br/><br/> my $result = &quot;&quot;;<br/> until ($chan-&gt;eof) {<br/> $chan-&gt;read(my $buf, 4_096);<br/> $result .= $buf;<br/> }<br/> chomp $result; # remove \n on string tail<br/><br/> return $result;<br/>}<br/><br/>seems to fix the problem. I am filling a bug against the module, but given<br/>that the last release was in 2009 and the most current version is less than<br/>1.0 (0.7), you may want to find a different module to use.<br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126780.html Tue, 13 Feb 2018 15:38:32 +0000 Re: ssh::command by Shlomi Fish Hi Lancelot, <br/> <br/>some comments on your code: <br/> <br/>On Tue, 13 Feb 2018 17:19:03 +0800 <br/>Lancelot Mak &lt;lancelot.mak@computer.org&gt; wrote: <br/> <br/>&gt; #!/usr/bin/perl -W <br/>&gt; <br/> <br/>1. don&#39;t use -w - http://perl-begin.org/tutorials/bad-elements/#the-dash-w-flag <br/> <br/>2. use strict and warnings instead. <br/> <br/>&gt; use SSH::Command; <br/>&gt; <br/>&gt; $cmdln = `grep $ARGV[0] list.txt`; <br/>&gt; chomp($cmdln); <br/> <br/>use file i/o or IO-All or Path-Tiny instead of ``: <br/>http://perl-begin.org/tutorials/bad-elements/#calling-the-shell-too-much <br/> <br/>&gt; ($cmdhost,$user,$pass) = split(&#39;:&#39;,$cmdln); <br/>&gt; $p = `echo $pass|base64 -d`; <br/>&gt; chomp($p); <br/>&gt; <br/> <br/>use https://metacpan.org/release/MIME-Base64 instead and avoid people snooping <br/>on ps. <br/>&gt; $cmdlog = ssh_execute( <br/>&gt; host =&gt; $cmdhost, <br/>&gt; username =&gt; $user, <br/>&gt; password =&gt; $p, <br/>&gt; command =&gt; &quot;$ARGV[1]&quot;, <br/>&gt; ); <br/>&gt; <br/> <br/>See http://perl-begin.org/tutorials/bad-elements/#vars_in_quotes . <br/> <br/>&gt; <br/>&gt; print $cmdlog; <br/>&gt; <br/>&gt; print &quot;\n&quot;; <br/>&gt; <br/>&gt; <br/>&gt; On 13 February 2018 at 16:36, Chas. Owens &lt;chas.owens@gmail.com&gt; wrote: <br/>&gt; <br/>&gt; &gt; Can you simplify your code to a short program that had the issue and post <br/>&gt; &gt; it? Often the act of shortening the program reveals the problem on its own. <br/>&gt; &gt; <br/>&gt; &gt; On Mon, Feb 12, 2018, 22:37 Lancelot Mak &lt;lancelot.mak@gmail.com&gt; wrote: <br/>&gt; &gt; <br/>&gt; &gt;&gt; Hi all, <br/>&gt; &gt;&gt; I am using SSH::Command module to do ssh stuff but it does not return <br/>&gt; &gt;&gt; full reply from server. Any clue? It just returns part of it. Is it <br/>&gt; &gt;&gt; timeout? or what? <br/>&gt; &gt;&gt; Thanks. <br/>&gt; &gt;&gt; <br/>&gt; &gt;&gt; <br/>&gt; &gt;&gt; -- <br/>&gt; &gt;&gt; -- <br/>&gt; &gt;&gt; Lancelot Mak <br/>&gt; &gt;&gt; <br/>&gt; &gt; <br/>&gt; <br/>&gt; <br/> <br/> <br/> <br/>-- <br/>----------------------------------------------------------------- <br/>Shlomi Fish http://www.shlomifish.org/ <br/>http://is.gd/htwEXQ - Integrating GNU Guile into GNU coreutils <br/> <br/>Give me ASCII or give me dea&thorn;! <br/> &mdash; http://www.shlomifish.org/humour.html <br/> <br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply . <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126779.html Tue, 13 Feb 2018 12:30:37 +0000 Re: Checking if a website is up doesn't work correctly by Shlomi Fish Hi Manfred! <br/> <br/>On Tue, 13 Feb 2018 12:25:31 +0100 <br/>Manfred Lotz &lt;ml_news@posteo.de&gt; wrote: <br/> <br/>&gt; Hi there, <br/>&gt; Somewhere I found an example how to check if a website is up. <br/>&gt; <br/>&gt; Here my sample: <br/>&gt; <br/>&gt; #! /usr/bin/perl <br/>&gt; <br/>&gt; use strict; <br/>&gt; <br/>&gt; use LWP::Simple; <br/>&gt; my $url=&quot;https://notabug.org&quot;; <br/>&gt; if (! head($url)) { <br/>&gt; die &quot;$url is DOWN!!!!&quot; <br/>&gt; } <br/>&gt; <br/>&gt; Running above code I get <br/>&gt; https://notabug.org is DOWN!!!! at ./check_url.pl line 8. <br/>&gt; <br/> <br/>This code seems to work fine here: <br/> <br/>#!/usr/bin/perl <br/> <br/>use strict; <br/>use warnings; <br/> <br/>use LWP::Simple; <br/> my $url=&quot;https://shlomif.github.io/&quot;; <br/># my $url=&quot;https://notabug.org/&quot;; <br/>if (! head($url)) { <br/> die &quot;$url is DOWN!!!!&quot;; <br/>} <br/> <br/>seems like notabug blocks libwww-perl. <br/> <br/> <br/>&gt; <br/>&gt; However, firefox shows the site works ok. <br/>&gt; <br/> <br/>same here. <br/> <br/>Regards, <br/> <br/> Shlomi <br/> <br/>&gt; <br/>&gt; What am I doing wrong? <br/>&gt; <br/>&gt; <br/> <br/> <br/> <br/>-- <br/>----------------------------------------------------------------- <br/>Shlomi Fish http://www.shlomifish.org/ <br/>Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/ <br/> <br/>&lt;talexb&gt; &ldquo;Hey, I have a flat tire. Can you help me change it with a can opener <br/>and a pound of sesame seeds?&rdquo; <br/> &mdash; talexb on parsing HTML or XML with regular expressions. <br/> <br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply . <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126778.html Tue, 13 Feb 2018 12:15:47 +0000 Checking if a website is up doesn't work correctly by Manfred Lotz Hi there,<br/>Somewhere I found an example how to check if a website is up.<br/><br/>Here my sample:<br/><br/>#! /usr/bin/perl<br/><br/>use strict;<br/><br/>use LWP::Simple;<br/>my $url=&quot;https://notabug.org&quot;;<br/>if (! head($url)) {<br/> die &quot;$url is DOWN!!!!&quot; <br/>}<br/><br/>Running above code I get<br/> https://notabug.org is DOWN!!!! at ./check_url.pl line 8.<br/><br/><br/>However, firefox shows the site works ok.<br/><br/><br/>What am I doing wrong?<br/><br/><br/>-- <br/>Thanks,<br/>Manfred<br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126777.html Tue, 13 Feb 2018 11:32:52 +0000 Re: ssh::command by Lancelot Mak #!/usr/bin/perl -W <br/> <br/>use SSH::Command; <br/> <br/>$cmdln = `grep $ARGV[0] list.txt`; <br/>chomp($cmdln); <br/>($cmdhost,$user,$pass) = split(&#39;:&#39;,$cmdln); <br/>$p = `echo $pass|base64 -d`; <br/>chomp($p); <br/> <br/>$cmdlog = ssh_execute( <br/>host =&gt; $cmdhost, <br/>username =&gt; $user, <br/>password =&gt; $p, <br/>command =&gt; &quot;$ARGV[1]&quot;, <br/>); <br/> <br/> <br/>print $cmdlog; <br/> <br/>print &quot;\n&quot;; <br/> <br/> <br/>On 13 February 2018 at 16:36, Chas. Owens &lt;chas.owens@gmail.com&gt; wrote: <br/> <br/>&gt; Can you simplify your code to a short program that had the issue and post <br/>&gt; it? Often the act of shortening the program reveals the problem on its own. <br/>&gt; <br/>&gt; On Mon, Feb 12, 2018, 22:37 Lancelot Mak &lt;lancelot.mak@gmail.com&gt; wrote: <br/>&gt; <br/>&gt;&gt; Hi all, <br/>&gt;&gt; I am using SSH::Command module to do ssh stuff but it does not return <br/>&gt;&gt; full reply from server. Any clue? It just returns part of it. Is it <br/>&gt;&gt; timeout? or what? <br/>&gt;&gt; Thanks. <br/>&gt;&gt; <br/>&gt;&gt; <br/>&gt;&gt; -- <br/>&gt;&gt; -- <br/>&gt;&gt; Lancelot Mak <br/>&gt;&gt; <br/>&gt; <br/> <br/> <br/>-- <br/>Lancelot Mak <br/>---------------------------------------------------------------- <br/>http://facebook.com/honey.mak <br/>Used to compete <br/>Lord to complete <br/>&aring;&frac34;&#158;&aring;&#137;&#141;&egrave;&frac14;&cedil;&egrave;&acute;&#143;&aring;&#156;&uml;&aring;&iquest;&#131;&eacute;&nbsp;&shy; <br/>&aring;&brvbar;&#130;&auml;&raquo;&#138;&auml;&cedil;&#128;&aring;&#136;&#135;&aring;&#156;&uml;&auml;&cedil;&raquo;&aelig;&#137;&#139; <br/>Amen <br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126776.html Tue, 13 Feb 2018 09:19:31 +0000 Re: ssh::command by Chas. Owens Can you simplify your code to a short program that had the issue and post<br/>it? Often the act of shortening the program reveals the problem on its own.<br/><br/>On Mon, Feb 12, 2018, 22:37 Lancelot Mak &lt;lancelot.mak@gmail.com&gt; wrote:<br/><br/>&gt; Hi all,<br/>&gt; I am using SSH::Command module to do ssh stuff but it does not return<br/>&gt; full reply from server. Any clue? It just returns part of it. Is it<br/>&gt; timeout? or what?<br/>&gt; Thanks.<br/>&gt;<br/>&gt;<br/>&gt; --<br/>&gt; --<br/>&gt; Lancelot Mak<br/>&gt;<br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126775.html Tue, 13 Feb 2018 08:36:39 +0000 re: ssh::command by Lancelot Mak Hi all,<br/> I am using SSH::Command module to do ssh stuff but it does not return<br/>full reply from server. Any clue? It just returns part of it. Is it<br/>timeout? or what?<br/> Thanks.<br/><br/>-- <br/>--<br/>Lancelot Mak<br/> https://www.nntp.perl.org/group/perl.beginners/2018/02/msg126774.html Tue, 13 Feb 2018 03:35:33 +0000 Re: `$#array` vs `scalar @array` by Chas. Owens Luckily in these cases, the faster answer is also the clearest answer in<br/>either case.<br/><br/>On Mon, Jan 29, 2018 at 5:32 PM Paul Johnson &lt;paul@pjcj.net&gt; wrote:<br/><br/>&gt; On Sun, Jan 28, 2018 at 10:57:25PM +0000, Chas. Owens wrote:<br/>&gt; &gt; $#array is the index of the last element of @array, so it will be one<br/>&gt; less<br/>&gt; &gt; than scalar @array which is the number of elements in @array (since Perl<br/>&gt; &gt; arrays start with index 0). Therefore, to get the number of elements, you<br/>&gt; &gt; would need to add one to $#array, which makes scalar @array faster. To<br/>&gt; get<br/>&gt; &gt; the last index you would need to say @array - 1, which would make $#array<br/>&gt; &gt; faster.<br/>&gt;<br/>&gt; But it doesn&#39;t matter, because this is not a bottleneck in your code.<br/>&gt;<br/>&gt; So code for clarity.<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; &gt; On Sun, Jan 28, 2018, 13:39 Peng Yu &lt;pengyu.ut@gmail.com&gt; wrote:<br/>&gt; &gt;<br/>&gt; &gt; &gt; Hi,<br/>&gt; &gt; &gt;<br/>&gt; &gt; &gt; For the following two expressions, are they of the same speed or one<br/>&gt; &gt; &gt; of them is faster?<br/>&gt; &gt; &gt;<br/>&gt; &gt; &gt; `$#array` vs `scalar @array`<br/>&gt;<br/>&gt; --<br/>&gt; Paul Johnson - paul@pjcj.net<br/>&gt; http://www.pjcj.net<br/>&gt;<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126773.html Tue, 30 Jan 2018 00:42:50 +0000 Re: `$#array` vs `scalar @array` by Paul Johnson On Sun, Jan 28, 2018 at 10:57:25PM +0000, Chas. Owens wrote:<br/>&gt; $#array is the index of the last element of @array, so it will be one less<br/>&gt; than scalar @array which is the number of elements in @array (since Perl<br/>&gt; arrays start with index 0). Therefore, to get the number of elements, you<br/>&gt; would need to add one to $#array, which makes scalar @array faster. To get<br/>&gt; the last index you would need to say @array - 1, which would make $#array<br/>&gt; faster.<br/><br/>But it doesn&#39;t matter, because this is not a bottleneck in your code.<br/><br/>So code for clarity.<br/><br/><br/><br/>&gt; On Sun, Jan 28, 2018, 13:39 Peng Yu &lt;pengyu.ut@gmail.com&gt; wrote:<br/>&gt; <br/>&gt; &gt; Hi,<br/>&gt; &gt;<br/>&gt; &gt; For the following two expressions, are they of the same speed or one<br/>&gt; &gt; of them is faster?<br/>&gt; &gt;<br/>&gt; &gt; `$#array` vs `scalar @array`<br/><br/>-- <br/>Paul Johnson - paul@pjcj.net<br/>http://www.pjcj.net<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126772.html Mon, 29 Jan 2018 22:49:20 +0000 Re: What is time, anyway? by SurfShop &gt; On Jan 29, 2018, at 12:18 PM, Octavian Rasnita &lt;orasnita@gmail.com&gt; wrote:<br/>&gt; <br/>&gt; from: perldoc -f time<br/>&gt; <br/>&gt; time Returns the number of non-leap seconds since whatever time the<br/>&gt; system considers to be the epoch, suitable for feeding to<br/>&gt; &quot;gmtime&quot; and &quot;localtime&quot;. On most systems the epoch is 00:00:00<br/>&gt; UTC, January 1, 1970; a prominent exception being Mac OS Classic<br/>&gt; which uses 00:00:00, January 1, 1904 in the current local time<br/>&gt; zone for its epoch.<br/><br/> For some reason, I never think to use perldoc. I don&#39;t know why. :\<br/><br/> UTC it is.<br/><br/>Thanks!<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126771.html Mon, 29 Jan 2018 21:02:35 +0000 Re: What is time, anyway? by Andy Bach YOu might look at localtime()<br/>perldoc.perl.org/functions/localtime.html<br/><br/>or gmtime<br/>perldoc.perl.org/functions/gmtime.html<br/><br/>time() returns the epoch time - seconds since Jan 1, 1970 UTC (IIRC),<br/>localtime transforms it to just that. So all your time() stamps will be<br/>the same and localtime() can turn them into a valid local version but if<br/>they&#39;re from all over, they won&#39;t have the TZ info, so you&#39;d have to handle<br/>that if you wanted to know &quot;when&quot; it happened where ever it actually<br/>happened. Hmmm, that may not matter ;-&gt;<br/><br/>a<br/><br/>On Mon, Jan 29, 2018 at 1:46 PM, SurfShop &lt;contactation@surfshopcart.com&gt;<br/>wrote:<br/><br/>&gt; Basic time question here. Looking at sites such as<br/>&gt; http://perldoc.perl.org/functions/time.html, I&#39;m not seeing what the<br/>&gt; time() function is based on. Does it return the time of the server, or<br/>&gt; UTC? Is it affected by any timezone setting on the server or in a script?<br/>&gt;<br/>&gt; I tested it in a script and the result didn&#39;t change when I added<br/>&gt; a timezone, so it doesn&#39;t look like that affects it. I also ran that<br/>&gt; script on both my server, which is in the EST timezone, and on my laptop,<br/>&gt; which is in the MST timezone, and I got the same answer. I&#39;m pretty sure<br/>&gt; that mean it&#39;s UTC, but I&#39;d like some assurance.<br/>&gt;<br/>&gt; The reason I&#39;m asking is that I want to be certain that if I use<br/>&gt; time() in multiple scripts, they will all be based on the same &#39;source&#39; so<br/>&gt; that any timestamp comparisons will be accurate. If there&#39;s a possibility<br/>&gt; that they won&#39;t be the same, then I&#39;ll need to convert them so that they<br/>&gt; will be the same.<br/>&gt;<br/>&gt; Thanks,<br/>&gt; Frank<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/><br/>-- <br/><br/>a<br/><br/>Andy Bach,<br/>afbach@gmail.com<br/>608 658-1890 cell<br/>608 261-5738 wk<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126770.html Mon, 29 Jan 2018 20:26:14 +0000 Re: What is time, anyway? by Octavian Rasnita from: perldoc -f time<br/><br/> time Returns the number of non-leap seconds since whatever time the<br/> system considers to be the epoch, suitable for feeding to<br/> &quot;gmtime&quot; and &quot;localtime&quot;. On most systems the epoch is 00:00:00<br/> UTC, January 1, 1970; a prominent exception being Mac OS Classic<br/> which uses 00:00:00, January 1, 1904 in the current local time<br/> zone for its epoch.<br/><br/><br/>--Octavian<br/><br/>----- Original Message ----- <br/>From: &quot;SurfShop&quot; &lt;contactation@surfshopcart.com&gt;<br/>To: &quot;Perl Beginners&quot; &lt;beginners@perl.org&gt;<br/>Sent: Monday, January 29, 2018 9:46 PM<br/>Subject: What is time, anyway?<br/><br/><br/>Basic time question here. Looking at sites such as <br/>http://perldoc.perl.org/functions/time.html, I&#39;m not seeing what the time() <br/>function is based on. Does it return the time of the server, or UTC? Is it <br/>affected by any timezone setting on the server or in a script?<br/><br/>I tested it in a script and the result didn&#39;t change when I added a <br/>timezone, so it doesn&#39;t look like that affects it. I also ran that script <br/>on both my server, which is in the EST timezone, and on my laptop, which is <br/>in the MST timezone, and I got the same answer. I&#39;m pretty sure that mean <br/>it&#39;s UTC, but I&#39;d like some assurance.<br/><br/>The reason I&#39;m asking is that I want to be certain that if I use time() in <br/>multiple scripts, they will all be based on the same &#39;source&#39; so that any <br/>timestamp comparisons will be accurate. If there&#39;s a possibility that they <br/>won&#39;t be the same, then I&#39;ll need to convert them so that they will be the <br/>same.<br/><br/>Thanks,<br/>Frank<br/>-- <br/>To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>For additional commands, e-mail: beginners-help@perl.org<br/>http://learn.perl.org/<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126769.html Mon, 29 Jan 2018 20:19:11 +0000 What is time, anyway? by SurfShop Basic time question here. Looking at sites such as http://perldoc.perl.org/functions/time.html, I&#39;m not seeing what the time() function is based on. Does it return the time of the server, or UTC? Is it affected by any timezone setting on the server or in a script? <br/> <br/> I tested it in a script and the result didn&#39;t change when I added a timezone, so it doesn&#39;t look like that affects it. I also ran that script on both my server, which is in the EST timezone, and on my laptop, which is in the MST timezone, and I got the same answer. I&#39;m pretty sure that mean it&#39;s UTC, but I&#39;d like some assurance. <br/> <br/> The reason I&#39;m asking is that I want to be certain that if I use time() in multiple scripts, they will all be based on the same &#39;source&#39; so that any timestamp comparisons will be accurate. If there&#39;s a possibility that they won&#39;t be the same, then I&#39;ll need to convert them so that they will be the same. <br/> <br/>Thanks, <br/>Frank https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126768.html Mon, 29 Jan 2018 19:47:04 +0000 Re: `$#array` vs `scalar @array` by Chas. Owens $#array is the index of the last element of @array, so it will be one less<br/>than scalar @array which is the number of elements in @array (since Perl<br/>arrays start with index 0). Therefore, to get the number of elements, you<br/>would need to add one to $#array, which makes scalar @array faster. To get<br/>the last index you would need to say @array - 1, which would make $#array<br/>faster.<br/><br/>On Sun, Jan 28, 2018, 13:39 Peng Yu &lt;pengyu.ut@gmail.com&gt; wrote:<br/><br/>&gt; Hi,<br/>&gt;<br/>&gt; For the following two expressions, are they of the same speed or one<br/>&gt; of them is faster?<br/>&gt;<br/>&gt; `$#array` vs `scalar @array`<br/>&gt;<br/>&gt; --<br/>&gt; Regards,<br/>&gt; Peng<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126767.html Sun, 28 Jan 2018 22:57:41 +0000 `$#array` vs `scalar @array` by Peng Yu Hi,<br/><br/>For the following two expressions, are they of the same speed or one<br/>of them is faster?<br/><br/>`$#array` vs `scalar @array`<br/><br/>-- <br/>Regards,<br/>Peng<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126766.html Sun, 28 Jan 2018 18:37:21 +0000 Re: What is the substitute for $#? by sisyphus1 <br/>From: Chas. Owens<br/>Sent: Saturday, January 27, 2018 9:04 AM<br/>To: Peng Yu<br/>Cc: Perl Beginners<br/>Subject: Re: What is the substitute for $#?<br/><br/>...<br/><br/>&gt; You can find the exact value of DBL_DIG on your system with the following <br/>&gt; C code:<br/><br/>...<br/><br/>The POSIX module will also tell you the value of DBL_DIG.<br/><br/>perl -MPOSIX -le &quot;print POSIX::DBL_DIG;&quot;<br/>15<br/><br/>In the event that &#39;perl -V:nvtype&#39; reports that nvtype is long double, you <br/>would use the value output by running:<br/><br/>perl -MPOSIX -le &quot;print POSIX::LDBL_DIG;&quot;<br/><br/>and if &#39;perl -V:nvtype&#39; reports __float128, then the POSIX module won&#39;t <br/>provide you with FLT128_DIG (which is 33).<br/><br/>Cheers,<br/>Rob<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126765.html Sat, 27 Jan 2018 00:54:55 +0000 Re: TLS and Perl by SurfShop &gt; On Jan 25, 2018, at 11:37 AM, David Precious &lt;davidp@preshweb.co.uk&gt; wrote:<br/>&gt; <br/>&gt; then that uses LWP::UserAgent under the hood for the communication with<br/>&gt; authorize.net; it doesn&#39;t set any SSL/TLS-specific options when calling<br/>&gt; LWP::UserAgent, unless you&#39;re causing it to yourself.<br/>&gt; <br/>&gt; LWP::UserAgent will use LWP::Protocol::https to talk to remote<br/>&gt; servers over SSL, using either IO::Socket::SSL or Net::SSLeay under the<br/>&gt; hood.<br/><br/> Perfect! Thanks, David. That&#39;s exactly what I needed to know.<br/><br/>Frank<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126764.html Fri, 26 Jan 2018 22:35:36 +0000 Re: Banning IP's with Net::Netmask by SurfShop &gt; On Jan 24, 2018, at 2:37 AM, Brandon Parncutt &lt;brandon.parncutt@gmail.com&gt; wrote: <br/>&gt; <br/>&gt; fail2ban would surely be the best bet here. <br/> <br/> Thanks, Brandon. I&#39;ll look into that if I can&#39;t find a pure Perl solution. It needs to be easily distributed with an OSS script. <br/> <br/>Frank https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126763.html Fri, 26 Jan 2018 22:25:02 +0000 Re: What is the substitute for $#? by Shlomi Fish Hi Peng, <br/> <br/>On Fri, 26 Jan 2018 15:33:43 -0600 <br/>Peng Yu &lt;pengyu.ut@gmail.com&gt; wrote: <br/> <br/>&gt; Hi, $# is deprecated. Could anybody let me know what is the substitute for it? <br/>&gt; <br/>&gt; https://perldoc.perl.org/perlvar.html <br/>&gt; <br/>&gt; $# was a variable that could be used to format printed numbers. After <br/>&gt; a deprecation cycle, its magic was removed in Perl v5.10.0 and using <br/>&gt; it now triggers a warning: $# is no longer supported. <br/>&gt; <br/> <br/>according to <br/>https://metacpan.org/pod/release/NWCLARK/perl-5.8.3/pod/perlvar.pod - it seems <br/>it used printf/sprintf format so just use those explicitly where needed. See: <br/> <br/>* http://perldoc.perl.org/functions/sprintf.html <br/> <br/>* http://perl-begin.org/uses/text-generation/ <br/> <br/>e.g: <br/> <br/> print &quot;I am &quot;, sprintf(&quot;%e&quot;, $age), &quot; years old.&quot;; <br/> <br/>Regards, <br/> <br/> Shlomi <br/>-- <br/>----------------------------------------------------------------- <br/>Shlomi Fish http://www.shlomifish.org/ <br/>http://www.shlomifish.org/humour/bits/New-versions-of-the-GPL/ <br/> <br/>A positive attitude may not solve all your problems, but it will annoy enough <br/>people to make it worth the effort. &mdash; Herm Albright (via On Gossamer Wings) <br/> <br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply . <br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126762.html Fri, 26 Jan 2018 22:24:27 +0000 Re: Banning IP's with Net::Netmask by SurfShop &gt; On Jan 24, 2018, at 2:37 AM, Brandon Parncutt &lt;brandon.parncutt@gmail.com&gt; wrote: <br/>&gt; <br/>&gt; fail2ban would surely be the best bet here. <br/> <br/> Thanks, Brandon. I&#39;ll look into that if I can&#39;t find a pure Perl solution. It needs to be easily distributed with an OSS script. <br/> <br/>Frank https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126761.html Fri, 26 Jan 2018 22:18:07 +0000 Re: What is the substitute for $#? by Chas. Owens Before it was removed, the docs say it was:<br/><br/>The output format for printed numbers. This variable is a half-hearted<br/>attempt to emulate awk&#39;s OFMT variable. There are times, however, when awk<br/>and Perl have differing notions of what counts as numeric. The initial<br/>value is &quot;%.ng&quot;, where n is the value of the macro DBL_DIG from your<br/>system&#39;s float.h. This is different from awk&#39;s default OFMT setting of<br/>&quot;%.6g&quot;, so you need to set $# explicitly to get awk&#39;s value. (Mnemonic: #<br/>is the number sign.)<br/><br/>So, you can probably get away with<br/><br/>printf &quot;%.15g\n&quot;, $var;<br/><br/>You can find the exact value of DBL_DIG on your system with the following C<br/>code:<br/><br/>#include &lt;stdio.h&gt;<br/>#include &lt;float.h&gt;<br/><br/>int main(int argc, char** argv) {<br/> printf(&quot;%d\n&quot;, DBL_DIG);<br/> return 0;<br/>}<br/><br/>Just put that in a file named dbl_dig.c and run<br/><br/>cc dbl_dig.c -o dbl_dig<br/><br/>and then run it:<br/><br/>./dbl_dig<br/><br/><br/><br/>On Fri, Jan 26, 2018 at 4:36 PM Peng Yu &lt;pengyu.ut@gmail.com&gt; wrote:<br/><br/>&gt; Hi, $# is deprecated. Could anybody let me know what is the substitute for<br/>&gt; it?<br/>&gt;<br/>&gt; https://perldoc.perl.org/perlvar.html<br/>&gt;<br/>&gt; $# was a variable that could be used to format printed numbers. After<br/>&gt; a deprecation cycle, its magic was removed in Perl v5.10.0 and using<br/>&gt; it now triggers a warning: $# is no longer supported.<br/>&gt;<br/>&gt; --<br/>&gt; Regards,<br/>&gt; Peng<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126760.html Fri, 26 Jan 2018 22:04:37 +0000 What is the substitute for $#? by Peng Yu Hi, $# is deprecated. Could anybody let me know what is the substitute for it?<br/><br/>https://perldoc.perl.org/perlvar.html<br/><br/>$# was a variable that could be used to format printed numbers. After<br/>a deprecation cycle, its magic was removed in Perl v5.10.0 and using<br/>it now triggers a warning: $# is no longer supported.<br/><br/>-- <br/>Regards,<br/>Peng<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126759.html Fri, 26 Jan 2018 21:33:50 +0000 Re: TLS and Perl by David Precious <br/>On Thu, 25 Jan 2018 10:19:26 -0800 SurfShop<br/>&lt;contactation@surfshopcart.com&gt; wrote:<br/>&gt; I keep getting emails from Authorize.net about their upcoming<br/>&gt; disablement of TLS 1.0 and TLS 1.1 and I need to know if that has<br/>&gt; anything to do with Perl or not. I don&#39;t have any code in SurfShop<br/>&gt; that references either SSL or TLS, so maybe that&#39;s handled by Perl<br/>&gt; itself or a module I&#39;m using like SSLeay.<br/><br/>Well, how do you interact with Authorize.net?<br/><br/>For instance, if you use Business::AuthorizeNet::CIM to deal with them,<br/>then that uses LWP::UserAgent under the hood for the communication with<br/>authorize.net; it doesn&#39;t set any SSL/TLS-specific options when calling<br/>LWP::UserAgent, unless you&#39;re causing it to yourself.<br/><br/>LWP::UserAgent will use LWP::Protocol::https to talk to remote<br/>servers over SSL, using either IO::Socket::SSL or Net::SSLeay under the<br/>hood.<br/><br/>In the absence of any specific instructions otherwise (which B::A::CIM<br/>doesn&#39;t provide), IO::Socket::SSL will use a sane, secure set of<br/>ciphers.<br/><br/>If LWP::UserAgent is using IO::Socket::SSL, then setting<br/>$IO::Socket::SSL::DEBUG to a suitable value should let you see what<br/>it&#39;s doing, and what ciphers it negotiates IIRC.<br/><br/>If you&#39;ve made use that the openssl library and the above-mentioned<br/>modules are up to date, you&#39;re likely to be fine.<br/><br/>I do believe they disabled TLS 1.0 on their testbed in advance though,<br/>so to be confident, point your code at their testbed and check that it<br/>works - if so, all is well!<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126758.html Thu, 25 Jan 2018 19:37:27 +0000 Re: TLS and Perl by SurfShop &gt; On Jan 25, 2018, at 10:43 AM, Darryl Philip Baker &lt;darryl.baker@northwestern.edu&gt; wrote: <br/>&gt; <br/>&gt; If you do not know TLS 1.0 and TLS 1.1 have a vulnerability in the design of the protocol and they are being deprecated. Currently only TLS 1.2 now and TLS 1.3 when finalized are considered safe. TLS 1.2 was defined in August of 2008 so if you are using anything developed in the last five years it should support TLS 1.2. <br/> <br/> Thanks, Darryl. Yes, that much I do know about TLS. I just didn&#39;t know if I needed to update anything on my end in the code. I don&#39;t want a bunch of angry emails from customers saying their cart&#39;s broken the day after the switch. ;) From your answer, it doesn&#39;t sound like I need to change anything. <br/> <br/> However, what if someone is still on Perl 5.8.8? That&#39;s older the last 5 years. Will that even make a difference? Where is TLS actually handled - in Perl, in the code, in the browser, on the server? This is the part that has me stumped. <br/> <br/>Thanks again, <br/>Frank https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126757.html Thu, 25 Jan 2018 19:28:36 +0000 Re: TLS and Perl by Darryl Philip Baker TLS is handled in the connection. So if your Perl code is opening the connection directly it would be in the SSLeay module and OpenSSL libraries. If your Perl cod is behind a webserver it is the webserver that handles the connection. Only if your Perl code is being distributed to others to run will you care what version of Perl others are running. <br/> <br/>Darryl Baker <br/>Sr. System Administrator <br/>Distributed Application Platform Services <br/>Northwestern University <br/>1800 Sherman Ave. <br/>Suite 6-600 &acirc;&#128;&#147; Box #39 <br/>Evanston, IL 60201-3715 <br/>darryl.baker@northwestern.edu <br/>(847) 467-6674 <br/> <br/>&iuml;&raquo;&iquest;On 1/25/18, 1:12 PM, &quot;SurfShop&quot; &lt;contactation@surfshopcart.com&gt; wrote: <br/> <br/> &gt; On Jan 25, 2018, at 10:43 AM, Darryl Philip Baker &lt;darryl.baker@northwestern.edu&gt; wrote: <br/> &gt; <br/> &gt; If you do not know TLS 1.0 and TLS 1.1 have a vulnerability in the design of the protocol and they are being deprecated. Currently only TLS 1.2 now and TLS 1.3 when finalized are considered safe. TLS 1.2 was defined in August of 2008 so if you are using anything developed in the last five years it should support TLS 1.2. <br/> <br/> Thanks, Darryl. Yes, that much I do know about TLS. I just didn&#39;t know if I needed to update anything on my end in the code. I don&#39;t want a bunch of angry emails from customers saying their cart&#39;s broken the day after the switch. ;) From your answer, it doesn&#39;t sound like I need to change anything. <br/> <br/> However, what if someone is still on Perl 5.8.8? That&#39;s older the last 5 years. Will that even make a difference? Where is TLS actually handled - in Perl, in the code, in the browser, on the server? This is the part that has me stumped. <br/> <br/> Thanks again, <br/> Frank <br/> <br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126756.html Thu, 25 Jan 2018 19:26:58 +0000 Re: TLS and Perl by Darryl Philip Baker If you do not know TLS 1.0 and TLS 1.1 have a vulnerability in the design of the protocol and they are being deprecated. Currently only TLS 1.2 now and TLS 1.3 when finalized are considered safe. TLS 1.2 was defined in August of 2008 so if you are using anything developed in the last five years it should support TLS 1.2. <br/> <br/>Darryl Baker <br/>Sr. System Administrator <br/>Distributed Application Platform Services <br/>Northwestern University <br/>1800 Sherman Ave. <br/>Suite 6-600 &acirc;&#128;&#147; Box #39 <br/>Evanston, IL 60201-3715 <br/>darryl.baker@northwestern.edu <br/>(847) 467-6674 <br/> <br/>&iuml;&raquo;&iquest;On 1/25/18, 12:19 PM, &quot;SurfShop&quot; &lt;contactation@surfshopcart.com&gt; wrote: <br/> <br/> I keep getting emails from Authorize.net about their upcoming disablement of TLS 1.0 and TLS 1.1 and I need to know if that has anything to do with Perl or not. I don&#39;t have any code in SurfShop that references either SSL or TLS, so maybe that&#39;s handled by Perl itself or a module I&#39;m using like SSLeay. <br/> <br/> Is there a write up on this anywhere? I&#39;ve searched for Perl and TLS but I haven&#39;t found anything that answers my question. I&#39;m not familiar with this side of things and I don&#39;t want orders to stop being processed in the cart when they switch over, so I&#39;m hoping someone knows more about this than I do. <br/> <br/> Thanks, <br/> Frank <br/> -- <br/> To unsubscribe, e-mail: beginners-unsubscribe@perl.org <br/> For additional commands, e-mail: beginners-help@perl.org <br/> https://urldefense.proofpoint.com/v2/url?u=http-3A__learn.perl.org_&amp;d=DwIFAg&amp;c=yHlS04HhBraes5BQ9ueu5zKhE7rtNXt_d012z2PA6ws&amp;r=tdje61_VHSXp608oLofeaJnnzo2Sr9_Cdcp70bBEtQ8&amp;m=spLFHsoESwLJ5AJkeI0RU2vWyyiJAdn9Z7BaDTsl1gc&amp;s=n-y-ZZg_ug39BomX0aKk1IsNnPfHE1dYC4b7yJEXD1E&amp;e= <br/> <br/> <br/> <br/> <br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126755.html Thu, 25 Jan 2018 18:44:00 +0000 TLS and Perl by SurfShop I keep getting emails from Authorize.net about their upcoming disablement of TLS 1.0 and TLS 1.1 and I need to know if that has anything to do with Perl or not. I don&#39;t have any code in SurfShop that references either SSL or TLS, so maybe that&#39;s handled by Perl itself or a module I&#39;m using like SSLeay. <br/> <br/> Is there a write up on this anywhere? I&#39;ve searched for Perl and TLS but I haven&#39;t found anything that answers my question. I&#39;m not familiar with this side of things and I don&#39;t want orders to stop being processed in the cart when they switch over, so I&#39;m hoping someone knows more about this than I do. <br/> <br/>Thanks, <br/>Frank https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126754.html Thu, 25 Jan 2018 18:19:37 +0000 Re: Banning IP's with Net::Netmask by Brandon Parncutt fail2ban would surely be the best bet here. It&#39;s based on Python but does<br/>exactly what you&#39;re describing and does it well...as long as your web app<br/>logs requests in a file somewhere.<br/><br/>On Jan 23, 2018 17:39, &quot;SurfShop&quot; &lt;contactation@surfshopcart.com&gt; wrote:<br/><br/>&gt; I&#39;m working on adding anti-hammering code to SurfShop to be able<br/>&gt; to temporarily ban visitors if they enter certain &quot;keywords&quot; into the query<br/>&gt; string, or if they repeatedly hammer the cart. I&#39;ve also set it up to be<br/>&gt; able to permanently block foreign IP&#39;s of the store owner&#39;s choosing. Each<br/>&gt; country&#39;s IPs are in separate text files and the temp IPs are in another,<br/>&gt; so there could be quite a few files. The temporary IPs also have a date<br/>&gt; associated with them, so they can be deleted later on.<br/>&gt;<br/>&gt; I decided to go with Net::Netmask for CIDR blocks but it&#39;s<br/>&gt; excruciatingly slow - it adds 2+ seconds to each page load in the cart.<br/>&gt; That&#39;s a deal breaker. If I remove the Net::Netmask section, the delay<br/>&gt; drops to about 1 second per page, but that&#39;s still visibly slower than<br/>&gt; without this sub.<br/>&gt;<br/>&gt; So I got the idea to keep track of the last 10?, 30?, 50? good IP<br/>&gt; addresses and not process those again after the first visit. The first<br/>&gt; page view gets the delay, but subsequent page speeds are normal. I&#39;ve<br/>&gt; included my code below and I&#39;m wondering what the problem is. Did I code<br/>&gt; something wrong? Did I choose the wrong module? Perhaps I&#39;m looking at<br/>&gt; this incorrectly. Is there a better way to do what I&#39;m after?<br/>&gt;<br/>&gt; The lines in the IP text files can be in any of these formats:<br/>&gt;<br/>&gt; 23.254.251.87<br/>&gt; 60.1.33.<br/>&gt; 41.96.0.0/12<br/>&gt; 11.22.33.44 2018-01-23<br/>&gt;<br/>&gt; Thanks,<br/>&gt; Frank<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; sub banned_ip_check($current_ip) {<br/>&gt; return unless $current_ip;<br/>&gt; my @ips = read_last_visitor_ips(); ## Last X visitors.<br/>&gt; foreach my $ip (@ips) {<br/>&gt; chomp $ip;<br/>&gt; return if $ip eq $current_ip; ## Only check the IP on first visit.<br/>&gt; }<br/>&gt; my $t2 = Time::Piece-&gt;new(); ## Today&#39;s date to compare with saved date.<br/>&gt; my @files = File::Find::Rule-&gt;file()<br/>&gt; -&gt;name(&#39;*.txt&#39;)<br/>&gt; -&gt;in(&quot;${data_dir}/banned_ips&quot;);<br/>&gt; foreach my $ip_file (@files) {<br/>&gt; open (my $ip_fh, &#39;&lt;&#39;, $ip_file) || SSLib::error(&quot;Xtras::banned_ip_check:<br/>&gt; Can&#39;t open $ip_file&quot;);<br/>&gt; while (my $line = &lt;$ip_fh&gt;) {<br/>&gt; chomp $line;<br/>&gt; my ($ip, $date) = split (/\s/, $line);<br/>&gt; my $process = &#39;yes&#39;;<br/>&gt; if ($date =~ m/\d+/) {<br/>&gt; $t1 = Time::Piece-&gt;strptime($date, &quot;%Y-%m-%d&quot;);<br/>&gt; if (($t2 - $t1) &gt; 2_600_000) { $process = &#39;no&#39; }<br/>&gt; }<br/>&gt; my $long = length($ip);<br/>&gt; my $found;<br/>&gt; if ($ip =~ m|/\d{2}$|) {<br/>&gt; ## CIDR IP Addresses<br/>&gt; my $block = Net::Netmask-&gt;new($ip);<br/>&gt; $found = &#39;yes&#39; if $block-&gt;match($current_ip);<br/>&gt; }<br/>&gt; if ($found || $process eq &#39;yes&#39; &amp;&amp; substr($current_ip, 0, $long)<br/>&gt; eq $ip) { ## Match partial IP&#39;s, too.<br/>&gt; deny_entry($current_ip, &#39;IP address&#39;, $ip_file);<br/>&gt; }<br/>&gt; }<br/>&gt; close ($ip_fh);<br/>&gt; }<br/>&gt; }<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/> https://www.nntp.perl.org/group/perl.beginners/2018/01/msg126753.html Wed, 24 Jan 2018 10:37:51 +0000