Disable Warning Messages In Perl..

Hi All,

I'm not a perl programmer, so please help me to disable warning messages. I tried like commenting 'use strict' and 'use warning' in perl program. But it is not working.

All I want is to disable warning messages.

Please note its not actual ping program, But a perl wrapper for ping to display ping output in color (Cope).

Below is output:

Code:
$ ./ping google.com
given is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 255.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 256.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 259.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope.pm line 262.
given is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 119.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 120.
given is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 159.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 160.
when is experimental at /usr/local/share/perl/5.20.2/App/Cope/Extra.pm line 161.
PING google.com (173.194.36.4) 56(84) bytes of data.
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=1 ttl=57 time=67.8 ms
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=2 ttl=57 time=68.1 ms
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=3 ttl=57 time=66.6 ms
64 bytes from bom04s01-in-f4.1e100.net (173.194.36.4): icmp_seq=4 ttl=57 time=66.6 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0 packet loss, time 3004ms
rtt min/avg/max/mdev = 66.687/67.353/68.155/0.743 ms

Works fine when error redirected to /dev/null
Code:
$ ./ping google.com 2>/dev/null
PING google.com (173.194.36.1) 56(84) bytes of data.
64 bytes from bom04s01-in-f1.1e100.net (173.194.36.1): icmp_seq=1 ttl=57 time=68.4 ms
64 bytes from bom04s01-in-f1.1e100.net (173.194.36.1): icmp_seq=2 ttl=57 time=66.6 ms
64 bytes from bom04s01-in-f1.1e100.net (173.194.36.1): icmp_seq=3 ttl=57 time=66.4 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0 packet loss, time 2003ms
rtt min/avg/max/mdev = 66.419/67.179/68.421/0.885 ms

Unfortunately, I cannot use output error redirection because all the perl programs are in PATH.

Actual ping perl program:
Code:
#!/usr/bin/env perl
use App::Cope;
use App::Cope::Extra qw[ping_time percent_b];
use Regexp::Common qw[net];

sub process {

  # header
  line qr{^PING (\S+)} => 'blue bold underline';

  # ping replies
  line qr{time=([0-9.]+ ms)\b}    => \&ping_time;
  mark qr{\($RE{net}{IPv4}\)}     => 'blue';
  line qr{(?:icmp_seq|ttl)=(\d+)} => 'bold';
  line qr{^(?:\d+ bytes )?[Ff]rom ([^:\s]+)} => 'blue bold';

  # final ping statistics
  line qr{(\d+% packet loss)} => \&{ percent_b 0, 1, 26 };
  line qr{min/avg/(?:max/mdev|ewma/max)\s=\s
	  ([0-9.]+)/    # minimum
	  ([0-9.]+)/    # average
	  ([0-9.]+)/    # maximum or moving average
	  ([0-9.]+\sms) # mean deviation or maximum
       }x => ( \&ping_time ) x 4;

}

run( \&process, real_path, @ARGV );

Code:
$ head -n15 /usr/local/share/perl/5.20.2/App/Cope.pm
#!/usr/bin/env perl
package App::Cope;
#use strict;
#use warnings;
use 5.010_000;
use Carp;

our $VERSION = '0.99';

=head1 NAME

App::Cope - Functions for the B<cope> program

=head1 SYNOPSIS

Code:
$ head -n15 /usr/local/share/perl/5.20.2/App/Cope/Extra.pm
#!/usr/bin/env perl
package App::Cope::Extra;
#use strict;
#use warnings;
use 5.010_000;

=head1 NAME

App::Cope::Extra - Pre-defined highlighting syntax for common patterns

=head2 SYNOPSIS

  use App::Cope::Extra;

  line qr{User: (\S+)} => \&{ user 'yellow' };

Thanks


Similar Content



How To Install Perl Module On RHEL?

Hello,

I need to install perl-Expect, so, I executed:

Code:
#  yum install -y perl-Expect
Error: Package: perl-Expect-1.21-14.el7.noarch (epel)
           Requires: perl(IO::Pty) >= 1.03
Error: Package: perl-Expect-1.21-14.el7.noarch (epel)
           Requires: perl(IO::Tty)

Okay, I need to install perl(IO::Pty)

I launched
Code:
# yum install -y "perl(IO::Pty)"
No package perl(IO::Pty) available.
Error: Nothing to do

So, how to install all required perl modules to the RHEL?

Perl One Liner To Delete Line In Csv File If One Columns Is Toobig

I have a little bash script that cats out a file and tells me if there is a line
where the 11th column has more than 6 characters in it.
It emails me where there is a bad line in a file - bead meaning that it will break a
donwstream process.

anyhow when i get the email saying that there is a bad file i just log in to the pc via
vpn and the I sed out the lines from the file that I get in the email. The bad lines are
always in danny.csv not danny1.csv
It has been the same lines killing the downstream process for a few weeks, so i put the "sed -i's" into
the script and it does it automagically.

[CODE]
for i in danny.csv danny1.csv
do
cat /come/and/play/with/$i | perl -ne 'print if length((split /,/)[10]) > 6' | mail -s "danny.csv bad line" casper@casperr.com
done

#it would be nice to find a perl change the file in place
sed -i '/D,642,0642,UBF,EVL,,M,,S,S,FOREVER,213,213,/d' /come/and/play/with/us/danny.csv
sed -i '/D,642,0642,UBF,EVL,,M,,S,S,QSP-U=C,4,4,/d' /come/and/play/with/us/danny.csv
[CODE]

However when a new line gets put into this file, I am going to have to log in and take out the line.
SO I have been trying to write a perl one liner that will edit the file in place, like sed, and make a
backup of the file. I just need a perl one liner that will delete any line where the 11th columns has more
than 6 characters in it.
[CODE]
perl -p -i.bak -e 's/\,\w{7}\,//g - which does not work.
[CODE]
I tried something like this:

[CODE]
perl -nle 'print if /\,\w{7}\,/' /come/and/play/with/us/danny.csv
[CODE]
but that does not catch the QSP-U=C and it catches more lines than just the
FOREVER. for a solutinog I need to focus on the the 11th column.

*** ERROR: PERL Module Apache::DBI Is Not Installed !

Hello,

I am configuring OCS Server using the following two documentations:

http://wiki.centos.org/HowTos/OCSNG
http://www.howtoforge.com/how-to-ins...-on-centos-5.5

Getting below error during installaton:

""Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for Apache:BI PERL module...
*** ERROR: PERL module Apache:BI is not installed !
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for Compress::Zlib PERL module...
Found that PERL module Compress::Zlib is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.
*** ERROR: There is one or more required PERL modules missing on your computer !
Please, install missing PERL modules first.""

i have googled for the solution unsuccessfully.
please help me in installing the missing perl module.

thanks in advance..

--
Anil Anji

Which Perl Module To Include To Use String Length Function?

HI all,
I'm writing a perl script to automate VM UUID transformation into a format used by our ServiceNow CMDB/discovery.

Anyone know which perl module to include to use the string length function?

Alternately, how would I determine which perl modules exist that are available to include, vs. which functions each module contains?

thanks in advance,
Tracy Wiseman, software engineer, Silicon Valley

Perl Script Not Running Via Cron

Hi All,

I have perl script which I am trying to run on 1st Monday via cron job.
So I scheduled it as follows:

0 0 1-7 * * root ["$(date '+%a')" = "Mon"] && /usr/bin/perl script.pl

But then it didn't run so checked cron log and it seemed like its missing the command. so added a \ in front of %a and then it picked up the whole command as per cron log.

But still it didnt ran the script. I then change the script to just && echo "test">/tmp/test

Still nothing. if I run it as /usr/bin/perl script.pl it runs though

Thanks in advance.

Sh: -c: Line 1: Syntax Error Near Unexpected Token `('

Hi,
I am working with a software that is based on Perl scripting and I have encountered with a bash scripting error. So as I am not familiar with bash scripting well, I don't know how I can solve.
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: ` 32(andRlooks_unw'

It should be mentioned that my $SHELL is /bin/bash. Could you please guide me what '-c' is? where is it? if I change the shebang (the #!/bin/sh part) to #!/bin/bash, the problem will be solved?

Regards,
Zahra

/var/log/messages Growing Tremendously

Hi, I can see the below mentioned logs writing every second into /var/log/messages.

"setroubleshoot: SELinux is preventing /usr/bin/perl from ioctl access on the file /usr/share/perl5/Exporter.pm. For complete SELinux messages. run sealert -l e6a1fd7e-a8c0-44bc-91db-b550f85f31c2"

Can anyone help me to find the root cause of this and how to fix it also?

Thanks in advance,

George

I Am Not Able To Ping Google.com.

Hi

I am not able to ping google.com.
I made the changes in ifcfg-eth0 IP address to static.it was dchp.

please help.

How To Redirect The Error Message?

I have a hostlist and there are several hosts. I want to use ssh to connect to them. I want to see whether the host is available or not by the time length of ssh takes. If it take long than 5s (which means it is not available). Then stop it, and ssh to next host. Once a host is available, then output the name of host. I previously use nmap, but the IT security told it is not allowed to install it on the desktop on campus.
Code:
    HOSTS=`cat $host_list`
    for line in $HOSTS
    do 
    ssh -o ConnectTimeout=5s $line true >> /dev/null
    RESULT=$?
    if [ $RESULT -eq 0 ]
    then
    echo $line > succeed.txt
    else
    echo $line > fail.txt
    fi
    done

The above script is all I can do.
The problem is when it is failed, I want to redirect the error message
Code:
ssh: connect to host c28-0112-05.ad.mtu.edu port 22: No route to host

. But I still get the error message.

Problem With Samba Share

Hello

I want to share a folder on my Fedora linux pc with a Windows 8 pc in the same network.

I have followed this guide : http://www.labtestproject.com/config...rver_on_fedora

but I am not able to see my share on my Fedora linux pc from the other Windows 8 PC.

This is my /etc/samba/smb.conf :

Code:
[global]
        workgroup = mygroup
        server string = HP Samba
;       netbios name = MYSERVER

;       interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
;       hosts allow = 127. 192.168.12. 192.168.13.

;       max protocol = SMB2
[My-Documents]
        path = /home/Jonas/Desktop/My-Documents
        read only = no
;       browseable = yes
        guest ok = yes


The workgroup name is the same as the workgroup name on the Windows PC.

Firewall on Fedora linux pc is down.

I do get the following output when restarting smb :
Code:
apr 27 12:27:49 jonashp.domain.local systemd[1]: Starting Samba SMB Daemon...
apr 27 12:27:49 jonashp.domain.local smbd[4324]: [2015/04/27 12:27:49.686796,  0] ../source3/param/loadparm.c:3034(lp_set_enum_parm)
apr 27 12:27:49 jonashp.domain.local smbd[4324]: WARNING: Ignoring invalid value 'share' for parameter 'security'
apr 27 12:27:49 jonashp.domain.local smbd[4324]: [2015/04/27 12:27:49.687187,  0] ../source3/smbd/server.c:1286(main)
apr 27 12:27:49 jonashp.domain.local smbd[4324]: standard input is not a socket, assuming -D option
apr 27 12:27:49 jonashp.domain.local systemd[1]: Started Samba SMB Daemon.

I thought it would be that simple...