perl or python

2010-10-05 Thread Kaushal Shriyan
Hi

Is it better to learn  Perl or Python since i can manage only writing
simple bash shell scripts.

Please suggest/guide.

Thanks and Regards

Kaushal

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




chomp () function

2010-08-29 Thread Kaushal Shriyan
Hi

Can someone please explain me with an example of the usage chomp ()
builtin function in perl.

Thanks

Kaushal

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: chomp () function

2010-08-29 Thread Kaushal Shriyan
On Sun, Aug 29, 2010 at 6:11 PM, Chas. Owens chas.ow...@gmail.com wrote:
 On Sun, Aug 29, 2010 at 07:15, Kaushal Shriyan kaushalshri...@gmail.com 
 wrote:
 Hi

 Can someone please explain me with an example of the usage chomp ()
 builtin function in perl.
 snip

 The chomp function removes whatever is in the $/ variable from the
 argument passed in (or $_ if no argument is passed in).  The default
 value of $/ is \n.  It is often used after reading a line to remove
 the newline (\n):


Hi Chas

$/ variable is a line separator variable whereas $_ is a default
variable. Please explain me when you said no argument is passed
so what i understand is chomp $line means $line is a argument ?

Thanks

Kaushal

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: chomp () function

2010-08-29 Thread Kaushal Shriyan
On Sun, Aug 29, 2010 at 7:06 PM, Chas. Owens chas.ow...@gmail.com wrote:
 On Sun, Aug 29, 2010 at 09:23, Kaushal Shriyan kaushalshri...@gmail.com 
 wrote:
 On Sun, Aug 29, 2010 at 6:11 PM, Chas. Owens chas.ow...@gmail.com wrote:
 On Sun, Aug 29, 2010 at 07:15, Kaushal Shriyan kaushalshri...@gmail.com 
 wrote:
 Hi

 Can someone please explain me with an example of the usage chomp ()
 builtin function in perl.
 snip

 The chomp function removes whatever is in the $/ variable from the
 argument passed in (or $_ if no argument is passed in).  The default
 value of $/ is \n.  It is often used after reading a line to remove
 the newline (\n):


 Hi Chas

 $/ variable is a line separator variable whereas $_ is a default
 variable. Please explain me when you said no argument is passed
 so what i understand is chomp $line means $line is a argument ?

 Thanks

 Kaushal


 Yes, $line is an argument that is passed to chomp in the code I sent
 earlier.  When you say

 chomp $line;

 then the $line variable will be affected, but if you say

 chomp;

 then the $_ variable will be affected.


Hi Chas

Thanks a lot Chas. Understood now.
Also what does $_ default variable means exactly, any example would
really help me understand it

Thanks

Kaushal

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: chomp () function

2010-08-29 Thread Kaushal Shriyan
On Sun, Aug 29, 2010 at 7:58 PM, Chas. Owens chas.ow...@gmail.com wrote:
 On Sun, Aug 29, 2010 at 09:41, Kaushal Shriyan kaushalshri...@gmail.com 
 wrote:
 snip
 Thanks a lot Chas. Understood now.
 Also what does $_ default variable means exactly, any example would
 really help me understand it
 snip

 The default variable is set or read by many Perl 5 functions.  For
 instance, if you use the readline operator () in a while loop's test
 it sets $_ and print uses $_ if no arguments are passed to it, so

 #!/usr/bin/perl

 use strict;
 use warnings;

 while (DATA) {
    print;
 }

 __DATA__
 foo
 bar
 baz

 will print the lines foo\n, bar\n, and baz\n.  $_ is also the
 default target for regexes, so

 #!/usr/bin/perl

 use strict;
 use warnings;

 while (DATA) {
    next unless /b/;
    print;
 }

 __DATA__
 foo
 bar
 baz

 Will print bar\n and baz\n, but not foo\n because it does not
 match the regex.

 --
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.


Hi Chas,

Thanks Chas.
Much appreciated :-)

I am referring to http://www.perl.org/books/beginning-perl/. so I am
planning to read upto chapter 10. is it recommended to even go beyond
chapter 10.
Please suggest.

How do i start writing my own perl scripts. Please suggest. Do you
recommend something else.

Kaushal

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




collectd application

2010-06-17 Thread Kaushal Shriyan
Hi,

For example I do wget -O file.png
http://collectd.example.com/collectd/cgi-bin/collection.cgi?action=show_plugin;host=testdb;timespan=day;plugin=mysql;
 for a single host testdb and plugin mysql

I do /usr/bin/mime-construct --header 'Sender: mor_...@test.com'
--header 'From: mor_...@test.com' --to y...@mail.com --subject 'Email
test' --file-attach /var/tmp/file.png

That would be a manual way of doing it. I do have numerous servers and
multiple plugins. Basically i would like to do it without manual
intervention.

Please suggest further to send multiple png files from multiple
servers with multiple collectd plugins.

is that possible using perl ?

Thanks,

Kaushal

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




directory exists

2009-12-02 Thread Kaushal Shriyan
Hi,

I have binary files 20080630 under a particular directory
(/mnt/data1/adserver/BinaryAdLogs) and there is a directory by the
name 2008_6_30 in /mnt/data1/adserver/DailyLogs

Basically i need to check the directory whether it exists in
/mnt/data1/adserver/DailyLogs for all the binary files located in
/mnt/data1/adserver/BinaryAdLogs

Please suggest/guide.

Thanks.

Kaushal

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




rsync perl script

2008-03-21 Thread Kaushal Shriyan
Hi

[EMAIL PROTECTED]
0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/

If i put this two lines in crontab it will run correctly,My requirement was
to create a perl script, this perl script should indicate success or
failures and the reason for failure

Any ideas

Thanks and Regards

Kaushal


Re: rsync perl script

2008-03-21 Thread Kaushal Shriyan
On Fri, Mar 21, 2008 at 2:36 PM, J. Peng [EMAIL PROTECTED] wrote:

 when running rsync with -v argument and when it get failed on
 executing, it will report the errors by itself.
 you could say my @info = `rsync -av ` in your perl scripts and
 check the executed results in the @info.

 On Fri, Mar 21, 2008 at 3:07 PM, Kaushal Shriyan
 [EMAIL PROTECTED] wrote:
  Hi
 
   [EMAIL PROTECTED]
   0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/
 
   If i put this two lines in crontab it will run correctly,My requirement
 was
   to create a perl script, this perl script should indicate success or
   failures and the reason for failure
 
   Any ideas
 
   Thanks and Regards
 
   Kaushal
 



Hi Peng,

so in this case the perl script would look like

##
#!/usr/bin/perl -w

my @info = rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/ ;
print @info;


##

Please let me know if its correct and is there any modification in the above
script

Thanks and Regards

Kaushal


FileHandle

2007-11-01 Thread Kaushal Shriyan
Hi

I am using FileHandle, Below is my code


#!/usr/bin/perl

use warnings;
use strict;

open(LOGFILE, messages)
|| warn Could not open messages;
open(DATA, /tmp/data) || die Could not create /tmp/data\n.

while (LOGFILE) {
print $_\n if /MARK/;
}
###

I am getting syntax error

I know i am doing wrong, please let me know whats causing the issue.

Thanks and Regards

Kaushal


Re: FileHandle

2007-11-01 Thread Kaushal Shriyan
Thanks Rob

Its working Fine, Now when I am using the below code to write something to
file messages
the below code is not writing the text write some text  to the file
messages.

##
#!/usr/bin/perl

use strict;
use warnings;

open(LOGFILE, messages)
|| warn Could not open messages.\n;
open(DATA, /tmp/data) || die Could not create /tmp/data\n.;

print LOGFILE write some text ;

##

when i do a less messages, i see there is no text write some text at the
end of the file.

what I am doing wrong.

Thanks and Regards

Kaushal


On 11/1/07, Rob Dixon [EMAIL PROTECTED] wrote:

 Kaushal Shriyan wrote:
  Hi
 
  I am using FileHandle, Below is my code
  
 
  #!/usr/bin/perl
 
  use warnings;
  use strict;
 
  open(LOGFILE, messages)
  || warn Could not open messages;
  open(DATA, /tmp/data) || die Could not create /tmp/data\n.
 
  while (LOGFILE) {
  print $_\n if /MARK/;
  }
  ###
 
  I am getting syntax error
 
  I know i am doing wrong, please let me know whats causing the issue.

 You have missed the semicolon from the end of your second 'open'
 statement.

 Rob



chomp operator

2007-10-30 Thread Kaushal Shriyan
Hi,

I have the below lines of code.

#!/usr/bin/perl
use strict;
use warnings;

my $text = a line of text\n ;
chomp($text); #the chomp operator gets rid of the newline character
print $text;

My question is if i remove the new line character \n in the above code
then i dont need the chomp operator if my understanding is correct.

so where does the chomp operator plays its role, can some one explain me
here with a sample of code.

Thanks and Regards

Kaushal


Pragmas use strict and use warnings

2007-10-30 Thread Kaushal Shriyan
Hi

Whats the exact purpose of use strict and use warnings Pragmas in the Perl
Programming Language.

I know use warnings turns on all useful warnings.

Thanks and Regards

Kaushal


Hash Variables

2007-10-29 Thread Kaushal Shriyan
Hi,

I have a sample code



#!/usr/bin/perl -w

%states = ( California,Sacramento, Wisconsin,Madison, New York,
Albany);

print Capital of California is  . $states{California} . \n\n;



I did not understand the statement $states{California} in the above print
statement of the code

I know the the dot is a concatenation operator and \n is a newline character

Thanks in Advance.

Thanks and Regards

Kaushal


Re: Hash Variables

2007-10-29 Thread Kaushal Shriyan
Hi

I am referring to perldoc perlintro
my %fruit_color = (apple, red, banana, yellow);

You can use whitespace and the = operator to lay them out more nicely:

   my %fruit_color = (
   apple  = red,
   banana = yellow,
   );

I know to use the Fat Comma Operator, How can one use the whitespace to lay
the Hash Key/Values Pair. Please explain me with the above example.

Thanks and Regards

Kaushal




On 10/29/07, Kaushal Shriyan [EMAIL PROTECTED] wrote:

 Hi,

 I have a sample code

 

 #!/usr/bin/perl -w

 %states = ( California,Sacramento, Wisconsin,Madison, New York,
 Albany);

 print Capital of California is  . $states{California} . \n\n;

 

 I did not understand the statement $states{California} in the above
 print statement of the code

 I know the the dot is a concatenation operator and \n is a newline
 character

 Thanks in Advance.

 Thanks and Regards

 Kaushal




Perl Scalars

2007-10-10 Thread Kaushal Shriyan
Hi,

I am referring to http://www.gnulamp.com/perlscalars.html

$a = $b; # Assign $b to $a

Note that when Perl assigns a value with *$a = $b* it makes a copy of $b and
then assigns that to $a. Therefore the next time you change $b it will not
alter $a.

I did not understand the Note:- Can some one make me understand this
statement with examples

and also what i understand from the below statements( I have added in the
comments), is it correct.

$a += $b;   #is it $a = $a + $b;
$a -= $b;#is it $a = $a - $b;
$a .= $b;#is it $a = $a . $b;

Thanks again

Thanks and Regards

Kaushal


Re: Perl Scalars

2007-10-10 Thread Kaushal Shriyan
On 10/10/07, Rob Dixon [EMAIL PROTECTED] wrote:

 Kaushal Shriyan wrote:
  Hi,
 
  I am referring to http://www.gnulamp.com/perlscalars.html
 
  $a = $b; # Assign $b to $a
 
  Note that when Perl assigns a value with *$a = $b* it makes a copy of $b
 and
  then assigns that to $a. Therefore the next time you change $b it will
 not
  alter $a.
 
  I did not understand the Note:- Can some one make me understand this
  statement with examples

 All they're saying is that $a = $b doesn't tie $a and $b together in any
 way,
 it just copies the value of $b to $a. If you change $b after that it won't
 alter $a again.

  and also what i understand from the below statements( I have added in
 the
  comments), is it correct.
 
  $a += $b;   #is it $a = $a + $b;
  $a -= $b;#is it $a = $a - $b;
  $a .= $b;#is it $a = $a . $b;

 Exactly right. Well done.

 Rob



Thanks Rob

All they're saying is that $a = $b doesn't tie $a and $b together in any
way, it just copies the value of $b to $a. If you change $b after that it
won't alter $a again.

Can you please explain me with a sample code. If I understand it correctly
does the below code  holds true for your explanation

#!/usr/bin/perl -w
$b = 2;
$a = $b;
print $a\n;
$b = 4;
$c = $b;
print $c\n;

Thanks again

Thanks and Regards

Kaushal


showmedo.com/videos

2007-10-09 Thread Kaushal Shriyan
Hi

The Showmedo.com videos has only 4 parts only what about the rest of the
videos or Am i seeing only 4 videos only

Thanks and Regards

Kaushal


Learning Perl

2007-10-07 Thread Kaushal Shriyan
Hi

I do not have any experience in programming at all. How do i start learning
Perl language. Can some one here point me to the right direction to learn
Perl Language

Thanks in Advance

Thanks and Regards

Kaushal


cgi script to capture http headers

2006-09-28 Thread Kaushal Shriyan

Hi ALL

I have a issue

when i use script (test.cgi)

#!/bin/bash
echo Content-type: text/plain;
echo
set

I get all the http headers populated with the values correctly

but when I use the below script (test-cgi)

#!/bin/sh

# disable filename globbing
set -f

echo Content-type: text/plain
echo

echo CGI/1.0 test script report:
echo

echo argc is $#. argv is $*.
echo

echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
echo SERVER_PORT = $SERVER_PORT
echo REQUEST_METHOD = $REQUEST_METHOD
echo HTTP_ACCEPT = $HTTP_ACCEPT
echo PATH_INFO = $PATH_INFO
echo PATH_TRANSLATED = $PATH_TRANSLATED
echo SCRIPT_NAME = $SCRIPT_NAME
echo QUERY_STRING = $QUERY_STRING
echo REMOTE_HOST = $REMOTE_HOST
echo REMOTE_ADDR = $REMOTE_ADDR
echo REMOTE_USER = $REMOTE_USER
echo AUTH_TYPE = $AUTH_TYPE
echo CONTENT_TYPE = $CONTENT_TYPE
echo CONTENT_LENGTH = $CONTENT_LENGTH

I dont get values for REMOTE_HOST = and REMOTE_USER =

I am calling the script http://mydomain.com/cgi-bin/test-cgi

Please let me know if you need any information

Thanks and Regards

Kaushal

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




cgi script

2006-09-28 Thread Kaushal Shriyan

Hi ALL

I have a issue when i use script (test.cgi)

#!/bin/bash
echo Content-type: text/plain;
echo
set

I get all the http headers populated with the values correctly

but when I use the below script (test-cgi)

#!/bin/sh

# disable filename globbing
set -f

echo Content-type: text/plain
echo

echo CGI/1.0 test script report:
echo

echo argc is $#. argv is $*.
echo

echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
echo SERVER_PORT = $SERVER_PORT
echo REQUEST_METHOD = $REQUEST_METHOD
echo HTTP_ACCEPT = $HTTP_ACCEPT
echo PATH_INFO = $PATH_INFO
echo PATH_TRANSLATED = $PATH_TRANSLATED
echo SCRIPT_NAME = $SCRIPT_NAME
echo QUERY_STRING = $QUERY_STRING
echo REMOTE_HOST = $REMOTE_HOST
echo REMOTE_ADDR = $REMOTE_ADDR
echo REMOTE_USER = $REMOTE_USER
echo AUTH_TYPE = $AUTH_TYPE
echo CONTENT_TYPE = $CONTENT_TYPE
echo CONTENT_LENGTH = $CONTENT_LENGTH

I dont get values for REMOTE_HOST = and REMOTE_USER =

I am calling the script http://mydomain.com/cgi-bin/test-cgi

Please let me know if you need any information

Thanks and Regards

Kaushal

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




NetSSH

2006-09-13 Thread Kaushal Shriyan

Hi ALL

My sshperl1.pl file contains the below

use Net::SSH::Perl;
   my $ssh = Net::SSH::Perl-new($tweb33.abc.test.com);
   $ssh-login($user, $pass);:
   my($stdout, $stderr, $exit) = $ssh-cmd($cmd);

I am getting the below error

this is the error
C:\perlscperl sshperl1.pl
Can't locate Net/SSH/Perl.pm in @INC (@INC contains: c:/Perl/lib c:/Perl/site/li
b .) at sshperl1.pl line 1.
BEGIN failed--compilation aborted at sshperl1.pl line 1.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: NetSSH

2006-09-13 Thread Kaushal Shriyan

On 9/13/06, Lee Goddard [EMAIL PROTECTED] wrote:

 I am getting the below error

 C:\perlscperl sshperl1.pl
 Can't locate Net/SSH/Perl.pm in @INC (@INC contains:
 c:/Perl/lib c:/Perl/site/li b .) at sshperl1.pl line 1.
 BEGIN failed--compilation aborted at sshperl1.pl line 1.

You need to install the module in question, Net::SSH::Perl.
The CPAN page for the module links to a README file that contains
instructions for the installation:

http://search.cpan.org/dist/Net-SSH-Perl/

http://search.cpan.org/src/DBROBINS/Net-SSH-Perl-1.30/README

If you are using ActivePerl you can probably get the Net::SSH package
with the command

   ppm install Net-SSH

You may find that Net::SSH is just as useful as Net::SSH::Perl.

HTH

http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal 
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on 
it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.




Hi Lee

Thanks for the quick turnaround

How do i install Net::SSH for windows version of perl on windows box. Any URL
to get the Net::SSH Perl module and install it using


ppm install Net-SSH


Thanks and Regards

Kaushal

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Query

2006-05-19 Thread Kaushal Shriyan

Hi All

#!/usr/bin/perl -w

whats -w flag stands for and what is its use, I mean How do i use it
and any other flags are also there, Please specify

Thanks

Kaushal

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Print

2006-05-18 Thread Kaushal Shriyan

Hi All

I have perl.chm file Learning Perl, How do i print all the chapters
and all pages in
the perl.chm file

when i click on print, only one page gets selected and in the print
dialog I can see only one page

How do i select all the pages so that I can print the entire book

Kaushal

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Hi

2006-05-14 Thread Kaushal Shriyan

Hi All

I am a novice to perl,I would like to learn perl in a systematic way,
Whats the best way to start with,I dont have any experience of
programming Language, But I came to know that perl is a Good
Programming Language

Thanks

Kaushal

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response