RE: How to retrieve a MAC address

2003-06-22 Thread Rai,Dharmender
this code would not work always as ifconfig runs in root login. 

> --
> From: Ashish Srivastava[SMTP:[EMAIL PROTECTED]
> Sent: Monday, June 23, 2003 9:38 AM
> To:   [EMAIL PROTECTED]
> Cc:   [EMAIL PROTECTED]
> Subject:  Re: How to retrieve a MAC address
> 
>  
>   Try following code on 'Linux'
>  
> #!/usr/bin/perl -w
> use strict;
> my @lines = `ifconfig`;
> my $fline = shift @lines;
> chomp $fline;
> $fline =~ /HWaddr\s+(.*)$/;
> print "$1\n";
> 
>  
> cheers
> Ashish
> ---Original Message---
>  
> From: [EMAIL PROTECTED]
> Date: Thursday, June 19, 2003 09:50:54 PM
> To: [EMAIL PROTECTED]
> Subject: How to retrieve a MAC address
>  
> Hi All,
>  
> I need to retrieve the MAC address of my local system from a Perl script.
> I'm running RedHat 7.2.
>  
> Can anyone point me to some sample code for accomplishing this? I've
> Googled
> for quite a while, and come up empty.
>  
> Alternatively, does anyone know where the MAC is stored on RedHat 7.2?
>  
> Thanks,
>  
> Aaron
>  
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>   
> 
> <>   IncrediMail - Email has finally evolved - Click Here
> 
> 

Confidential:  This electronic message and all contents contain information
from Syntel, Inc. which may be privileged, confidential or otherwise
protected from disclosure. The information is intended to be for the
addressee only. If you are not the addressee, any disclosure, copy,
distribution or use of the contents of this message is prohibited.  If you
have received this electronic message in error, please notify the sender
immediately and destroy the original message and all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Change of mail id from vemav@anz.com to venkatsb@anz.com

2003-06-22 Thread Vema, Venkata



 
Can you Change my mail id from [EMAIL PROTECTED] to [EMAIL PROTECTED]

  -Original Message- From: Ashish 
  Srivastava [mailto:[EMAIL PROTECTED] Sent: Mon 23/06/2003 
  2:08 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] 
  Subject: Re: How to retrieve a MAC address
  

  
 
 Try following code on 'Linux'
 
#!/usr/bin/perl -wuse strict;my @lines = `ifconfig`;my 
$fline = shift @lines;chomp $fline;$fline =~ 
/HWaddr\s+(.*)$/;print "$1\n";
 
cheers
Ashish
---Original 
Message---
 

From: [EMAIL PROTECTED]
Date: Thursday, June 
19, 2003 09:50:54 PM
To: [EMAIL PROTECTED]
Subject: How to 
retrieve a MAC address
 
Hi All,
 
I need to retrieve the MAC address of my local system from a Perl 
script.
I'm running RedHat 7.2.
 
Can anyone point me to some sample code for accomplishing this? 
I've Googled
for quite a while, and come up empty.
 
Alternatively, does anyone know where the MAC is stored on RedHat 
7.2?
 
Thanks,
 
Aaron
 
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 

  

  
  


  IncrediMail 
  - Email has finally evolved - Click 
  Here

Re: How to retrieve a MAC address

2003-06-22 Thread Ashish Srivastava






 
 Try following code on 'Linux'
 
#!/usr/bin/perl -wuse strict;my @lines = `ifconfig`;my $fline = shift @lines;chomp $fline;$fline =~ /HWaddr\s+(.*)$/;print "$1\n";
 
cheers
Ashish
---Original Message---
 

From: [EMAIL PROTECTED]
Date: Thursday, June 19, 2003 09:50:54 PM
To: [EMAIL PROTECTED]
Subject: How to retrieve a MAC address
 
Hi All,
 
I need to retrieve the MAC address of my local system from a Perl script.
I'm running RedHat 7.2.
 
Can anyone point me to some sample code for accomplishing this? I've Googled
for quite a while, and come up empty.
 
Alternatively, does anyone know where the MAC is stored on RedHat 7.2?
 
Thanks,
 
Aaron
 
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 







  IncrediMail - Email has finally evolved - Click Here

RE: Exchange Server Mailbox format

2003-06-22 Thread Tim Johnson

I don't think Microsoft will ever give out the exact format that their
database is in for parsing, for obvious reasons.  If you want to parse the
contents of mailboxes, I would recommend checking out the Win32::Exchange
module and a good long research session at www.microsoft.com/msdn.  You can
use Win32::OLE to do almost anything that a vbscript can do.  I would also
recommend trying out OutlookSpy.  I can't remember where I got it, but do a
search on Google and you should find it.  It definitely helps when it comes
to finding methods and objects that you can use if you decide to go the
Win32::OLE route.  Here's some code I started when I was looking into the
same kind of thing.

Of course, this must be done on a Win32 system.


use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
use Time::Local;

print "Opening a new MAPI.Session object...\n";
my $session = Win32::OLE->new('MAPI.Session') or die "Couldn't create a new
MAPI.Session object!\n$!\n";

print "Logging on...\n"; 
$session->Logon();

print "Opening the Inbox...\n";
my $inbox = $session->Inbox || die;

print "Getting the list of folders...\n";
my @folders = ();
my $folders = $inbox->Folders || die;
my $folder = $folders->GetFirst || die;
while($folder){
push @folders,$folder->Name;
$folder = $folders->GetNext;
}

print "\n\n";
print "Folders\n";
print "==\n";
foreach(sort @folders){
print "  $_\n";
}

print "\n\n";
print "Messages\n";
print "==\n";

print "Getting the Messages...\n";  
my $messages = $inbox->Messages || die;

print "Getting the first message...\n";
my @msgs = ();
my $message = $messages->GetFirst || die;

while($message){
my $msgtime = $message->TimeReceived;
my @temparray = ($message,$msgtime);
push @msgs,[EMAIL PROTECTED];
$message = $messages->GetNext;
}

foreach my $item(@msgs){
my @date = split /\s+/,@{$item}[1];
my($mon,$mday,$year) = split /\//,$date[0];
my($hour,$min,$sec) = split /:/,$date[1];
if($date[2] eq 'PM'){
$hour += 12;
}
if($hour == 24){
$hour = 0;
}
push @{$item},timelocal($sec,$min,$hour,$mday,$mon,$year);
}
my $i;  
foreach my $msg(sort{$b->[2] cmp $a->[2]} @msgs){
if($msg->[0]->FolderID eq $inbox->ID){
print "\n\n";
print "Received: ".$msg->[0]->TimeReceived."\n";
print "Subject: ".$msg->[0]->Subject."\n";
print "From: ".$msg->[0]->Sender->DisplayName."\n\n";
print $msg->[0]->Text;
print "\n";
print
"--=#==---\n";
}
$i++;
if($i > 10){
exit 0;
}
}

###

-Original Message-
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 21, 2003 1:25 PM
To: Morrison, Trevor (Trevor)
Cc: [EMAIL PROTECTED]
Subject: Re: Exchange Server Mailbox format


"Morrison, Trevor (Trevor)" wrote:

> Hi,
>
> Does anyone know which mail box storage format an 2000 exchange server
uses.  I am looking to parse emails that are stored in the folders.

You should probably search the Microsoft knowledge base for that
information.  It is not really a Perl question.  There may be Perl modules
that can parse those mailboxes, though.

As a note:  Please do not use return receipt requests when posting to this
group.  They are annoying and intrusive.

Joseph

>
>
> Thanks
>
> Trevor


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: perl question

2003-06-22 Thread Pavle Lukic
On Sat, Jun 21, 2003 at 12:40 PM -0700, Ioana Cozmuta wrote:

>>I do understand the problem, however I do not know how to put it in a perl
>>script. For example, in C this could be solved using pointers.
>>As I mentioned in my first e-mail, the data are tab delimited. If between
>>the tabs there is no value, then I know that one value is missing and I
>>also know at which position the value is missing because the pointer could
>>tell me the exact position in the line.
>>
>I think the following code is closely what you need:
>while () {
> chomp;
> s/\t\t/\t0\t/g; # insert 0
> push @arr, [  split (/\t/, $_) ];
>}
>

If there were more than two tabs in a row, 
the provided code needed adjustment.
One solution is here:

while () {
chomp;
while ($_ =~ /\t\t/g) {
s/\t\t/\t0\t/;}
push @arr, [ split (/\t/, $_) ];
}


Pavle

Re: perl question

2003-06-22 Thread Pavle Lukic
On Sat, Jun 21, 2003 at 12:40 PM -0700, Ioana Cozmuta wrote:

>I do understand the problem, however I do not know how to put it in a perl
>script. For example, in C this could be solved using pointers.
>As I mentioned in my first e-mail, the data are tab delimited. If between
>the tabs there is no value, then I know that one value is missing and I
>also know at which position the value is missing because the pointer could
>tell me the exact position in the line.
>I understand that there are 10 columns with data at most delimited by
>tabs. When for example data is missing at position 3 then the line would
>read >data\tdata\t\tdata...
>or at position 4
>data\tdata\tdata\t\tdata\tdata...
>When I say the data is missing I mean there is no value at all present,
>not even a zero (that would make things easier).
>I also know that when a value is present it is at least a character (0).
>Thus I could identify with a pointer the locations where I have \t\t
>versus \tdata\t.

I think the following code is closely what you need:

while () {
 chomp;
 s/\t\t/\t0\t/g; # insert 0
 push @arr, [  split (/\t/, $_) ];
} 


Regards


Pavle

Re: Writing Platform Independant Perl Code

2003-06-22 Thread Jenda Krynicky
From: "R. Joseph Newton" <[EMAIL PROTECTED]>
> perl_beginner wrote:
> 
> >  While the code works fine with Linux, crumbles on XP saying "Can't
> >  find
> > string terminator "EOM" anywhere before EOF at recordProxy.pl line
> > 317". Line 317 in my code is: $response= <<"EOM";
> 
> To start with, you should lose the quotes around EOM in the opening of
> the string assignment above. I'm not sure that those in themselves
> would cause the code to fail, but they make it more confusing.

I disagree. Yes, the quotes are not required there, but it would 
still be better to keep them. So that you do not have to wonder 
whether 
$response = 

RE: File::Find

2003-06-22 Thread Ronen Kfir
Hi,
This is a production script, not homework!

The follow is a script I wrote designed to send mail messages with predefined 
attachments, as an alerts coming from Big Brother system. 
That is how it works: As soon as mail arrives from Big Brother, files named "down" & 
"up" generated by a .procmailrc file. The down & up files are trigger files that once 
exists, generate a mail massage with the predefined attachment (which are different 
for, which is specific for each server & service (there are 23 servers & 4 services). 
There is a directory tree of all servers & services. Each time down & up files 
generates in the right path respectively to the service+server damaged. 
I wrote this script for a single server+service. My problem now is how to make this 
work with multiple server+service. 

___
#!/usr/bin/perl

use strict;
use warnings;
use Net::SMTP;
use MIME::Lite;

# defenitions
my $from_address = '[EMAIL PROTECTED]';
my $to_address = '[EMAIL PROTECTED]';
my $mail_host = 'post.tau.ac.il';
my $msg;
my $subject = 'sms alert';
my $message_body = "attached message";
my $trigger_down= '/Big_Brother/attachments/faxsrv/svcs/down';
my $trigger_up= '/Big_Brother/attachments/faxsrv/svcs/up';
my $attachment_down= '/Big_Brother/attachments/faxsrv/svcs/down.asc';
my $attachment_up= '/Big_Brother/attachments/faxsrv/svcs/up.asc';


# create down mail message+ attachment

if (-e $trigger_down) {
$msg = MIME::Lite->new (
  From => $from_address,
  To => $to_address,
 Subject => $subject,
  Data => $message_body,
  Type =>'TEXT',
) or die "Error creating mail message: $!\n";

$msg->attach (

  Path =>$attachment_down,
  Filename=>'down.asc',
) or die "Error adding the text message part: $!\n";

MIME::Lite->send('smtp', $mail_host, Timeout=>60);
$msg->send;
}

unlink $trigger_down;

# creating up mail message+ attachment

if (-e $trigger_up) {
$msg = MIME::Lite->new (
  From => $from_address,
  To => $to_address,
 Subject => $subject,
  Data => $message_body,
  Type =>'TEXT',
) or die "Error creating mail message: $!\n";

$msg->attach (
  Path =>$attachment_up,
  Filename=>'up.asc',
) or die "Error adding the text message part: $!\n";

MIME::Lite->send('smtp', $mail_host, Timeout=>60);
$msg->send;
}
unlink $trigger_up;



used file::find module with this code peace :


@ARGV = qw(/Big_Brother/attachments) unless @ARGV;
use File::Find;
#open DOWN > @down;
find sub { print $File::Find::name, -f && '*', "\n"
}, @ARGV;

this marked all files  with a * at the end. How do I put those paths I find to an 
array, so I can match them with the rest of the script?




?Ronen Kfir
System Administrator
T.A.U Computing Division
Tel: 972-3-6407416
Fax: 972-3-6405158
cellular: 972-55-405910
E-mail: [EMAIL PROTECTED]


-Original Message-
From: R. Joseph Newton [mailto:[EMAIL PROTECTED] 
Sent: Saturday, June 21, 2003 9:29 PM
To: Ronen Kfir
Cc: [EMAIL PROTECTED]
Subject: Re: readir

Ronen Kfir wrote:

> Hi,
>
> This is not I was asking for!
> I'll explain again:
> 1.  Find all the places where a one specific file (with same name), is shown by read 
> recursively all subdir of certain directory (it is a trigger file for the rest of my 
> program). What you wrote is only the top level of the directory.
> 2. What I'm interested in are the paths of this file in the various directories. I 
> need to put each of those paths as a variable. (I think in array/hash).
> 3. then I go to each path & from there pick up another file with same name from all 
> different paths, then my program will go on.
>
> To make a long story short: I need the readdir switch (or anything else) for digging 
> into subdir, & a way to put the paths I find in array/hash.
> Am I clear enough now?
>
> P.S.
> I work on Linux,
>
>
>  Ronen Kfir

Then get to work!  Look, you are dictating first the method that must be used, and 
then demanding that we present you with some finished product to accomplish this.  
What have you tried?  Where are you stuck?

As some have pointed out, the File::Find module can do this job for you.  See if the 
mocule is installed, and install it if not.  Then do
perldoc File::Find
and use the information contained therein to solve your problem.

Unfortunately, using the module does not teach you anything about how to construct a 
well-ordered recusive system.  Is this what you are working on?  Is this the focus of 
your homework assignment?

If so, you will need to create a function which scans through a diretory seeking the 
file, and  calls itself on all subdirectories.  To do this effectively, you will have 
to be comfortable and skilled with passing values, both by value
and by reference, to functions.  How are your skills in this regard?

Please show some of the work that you are doing to accomplish this task, and you will 
get more help.

Joseph


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:

Re: Can LWP::Simple tranfer image urls?

2003-06-22 Thread Jerry Rocteur
Finally, some usefull stuff in Perl ;-))

On Saturday, Jun 21, 2003, at 18:52 Europe/Brussels, Randal L. Schwartz 
wrote:

The code for 2001, 2002, and 2003 is in the thread starting at:

  


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: readir

2003-06-22 Thread Charles K. Clarkson
Josimar Nunes de Oliveira <[EMAIL PROTECTED]> wrote:
: 
: Hello Clarkson,
: Thanks for everything you explained.

You're welcome.
 
: The 'System Volume Information' is a restricted system folder 
: (only SYSTEM can access) in NTFS.

I don't know much about win 2k. That file may
be inaccessible to the user running the script.
Sorry, but I don't know how to access it.

 
: For a moment I was in trouble in how to handle the @file 
: resulted from the
: File::Find.
: It´s a basic problem that I need to understand how to access 
: array and hash.
: I must improve my skill toward this subject.
: The final porpose isn´t important by now, only learning a 
: litle more Perl:
: I tried this and worked fine:
: 
: for (my $i=0; $i<=$#files; $i++){
:  print "\n", $files[$i][0], ' => ', $files[$i][1];
: }

In perl you can usually step through a single
array *without* counting through its indexes. It
may look funny at first, but this is easier to
read.

foreach my $file ( @files ) {
print join( ' => ', @$file ), "\n";
}

Each time through the loop $file contains a
reference to another array. 'perldsc' has a lot
info on data structures like this.


: How to sort the @file by filename (first column of array)?
: How can take every occurrency of array with foreach(@files) 
: or while (@files) like in loop above?

Sorting this array should be fairly
straight forward.

# ascending first column sort
@files = sort { $a->[0] cmp $b->[0] } @files;

# ascending second column sort
@files = sort { $a->[1] cmp $b->[1] } @files;


# Descending first column sort
@files = reverse sort { $a->[0] cmp $b->[0] } @files;

# Descending second column sort
@files = reverse sort { $a->[1] cmp $b->[1] } @files;


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


Or a 1 column sort sub routine where a negative value
will do a reverse (or descending) sort:


sort_files( -1, [EMAIL PROTECTED] );

foreach my $file ( @files ) {
print join( ' => ', @$file ), "\n";
}

sub sort_files {
my( $column, $array ) = @_;

my $descending = $column < 0;
$column = abs( $column ) - 1;
die if $column < 0;

# ascending sort
@$array =
sort
{ $a->[ $column ] cmp $b->[ $column ] }
@$array unless $descending;

# descending sort
@$array = reverse
sort
{ $a->[ $column ] cmp $b->[ $column ] }
$array;
}






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]