Re: File Size Calculator

2004-08-10 Thread SilverFox
Jose Alves De Castro wrote:

 On Mon, 2004-08-09 at 14:53, David Dorward wrote:
 On 9 Aug 2004, at 14:34, SilverFox wrote:
 
  Hi all, I'm trying to writing a script that will allow a user to enter
  a
  number and that number will be converted into KB,MB or GB depending on
  the
  size of the number. Can someone point me in the right direction?
 
 What have you got so far? Where are you stuck? Getting user input
 (where from)? Working out which order of magnitude the number is?
 
 I wouldn't do that (the part of finding the order of magnitude)... I
 would probably keep on doing calculations while the numbers was greater
 then 1024... and in the end, when it was, the right letter to append
 would be based on the amount of calculations done...
 
 I remember reading something about this on use.Perl ... it was a while
 ago, and I'm not sure whether it ever got into a module, but the guy had
 written some wonderful code to do this :-)
 
 Converting between kilo and mega et al? Showing the output?
 
 Show us some code.
 
 --
 David Dorward
   http://dorward.me.uk/
 http://blog.dorward.me.uk/

I haven't put anything together as yet. Putting some if/elsif statement 
together would be the easies way I can think off. Something like:

$kilo= 1024;
$Mega= 1048576;
$gig= 1073741824;

print Please enter your number:\n;
chomp($num=STDIN);

if ($num = $gig) 
{
need code to do the convertion/rounding of given number
print you entered: $num\n;
print which is:
} elsif {
continue with the same format

}

The problem i'm having it converting/rounding the inputted number into a 
valid byte (KB/MB/GB) count.

SilverFox

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




File Size Calculator

2004-08-09 Thread SilverFox
Hi all, I'm trying to writing a script that will allow a user to enter a 
number and that number will be converted into KB,MB or GB depending on the 
size of the number. Can someone point me in the right direction?

Example: 
user enter: 59443
Script will output: 58M


SilverFox

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




Variable matching.....

2004-03-09 Thread SilverFox
Hi all, I'm trying to figure out how can I check if a variable matches the 
first 5 digits of the line below without removing anything from the line. 

13384 R 20020920 N Gatekeeper, The

Silver Fox

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




checking duplicates

2003-12-30 Thread SilverFox
Hi all, i'm trying to figure out how I can check for duplicates entries in 
an array and remove the duplicate.

Example:
23,23,39,40,44,44
should result in:
23,39,40,44

I'm reading from a file and assigning it to an array.

Silver Fox

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




Playing with Numbers

2003-11-10 Thread SilverFox
Hi all, i'm trying to figure out how to test if a number is five digits and 
if not add zero/s in front to make it 5 digits. Any ideas?

Examples:

444  = 00444
4120 = 04120
23   = 00023

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



command-line

2003-11-01 Thread SilverFox
hey guys, i'm trying to grep some data from a log file and getting the 
following error. Any ideas???

[EMAIL PROTECTED] perl -e 'grep \Eliminating movie\ update.log |awk {'print 
\$5'}';

Can't find string terminator '' anywhere before EOF at -e line 1.

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



slice and dice them

2003-09-30 Thread SilverFox
can anyone tell me how I can remove the period at the end of each line 
below??

.
.
.
.



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



who's the master????

2003-09-30 Thread SilverFox
hey guys, I'm trying to figure out how to stripe Anything Else, 7:15pm 
and 9:50pm from the below html code. Any ides? 

tdfont class=smalllista 
href=/showtimes/movie.adp?movieid=16038date=20030929theaterid=757 
Anything Else/a nbsp;nobr(R, 108 min.)/nobrbra 
href=https://tickets.moviefone.com/ticketing/order.adp?movieid=16038theaterid=757showdate=20030929showtime=1915screenId=3
 
7:15pm/a | a 
href=https://tickets.moviefone.com/ticketing/order.adp?movieid=16038theaterid=757showdate=20030929showtime=2150screenId=3
 
9:50pm/a/font/td

I'm trying to use curl on my linux box to grab data from this web 
siteheheheh

Thx

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



Re: who's the master????

2003-09-30 Thread SilverFox
Thanks budwill look into that..



Ramprasad A Padmanabhan wrote:

 Silverfox wrote:
 hey guys, I'm trying to figure out how to stripe Anything Else,
 7:15pm and 9:50pm from the below html code. Any ides?
 
 tdfont class=smalllista
 href=/showtimes/movie.adp?movieid=16038date=20030929theaterid=757
 
Anything Else/a nbsp;nobr(R, 108 min.)/nobrbra
 
 
href=https://tickets.moviefone.com/ticketing/order.adp?movieid=16038theaterid=757showdate=20030929showtime=1915screenId=3
 
7:15pm/a | a
 
 
href=https://tickets.moviefone.com/ticketing/order.adp?movieid=16038theaterid=757showdate=20030929showtime=2150screenId=3
 
9:50pm/a/font/td
 
 
 I'm trying to use curl on my linux box to grab data from this web
 siteheheheh
 
 Thx
 
 You can easily write regular expressions to extract whatever is there
 between a .. /a and you can find ample help for that on the net, But
 just a sec there are hundreds of modules that can do html parsing. It
 would initially take some effort to install one and learn the syntax ,
 But then You will never have any problems after that.
 
 For your problem try HTML::LinkExtor
 Hope that helps
 Ram


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



Cutting Variable

2003-08-17 Thread SilverFox
Hi all...how can I pull the number from the given path??

/Machine4/dir/dir/dir

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



Re: :Telnet

2003-08-17 Thread SilverFox
David Storrs wrote:

 On Mon, Aug 11, 2003 at 09:42:40AM -0400, Stephen Gilbert wrote:
  -Original Message-
  From: SilverFox [mailto:[EMAIL PROTECTED]
  Sent: Sunday, August 10, 2003 4:58 PM
  To: [EMAIL PROTECTED]
  Subject: Net::Telnet
  
  
  hey anyone know how to check if a file exists using the Telnet module?
  
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
 try:
 $file_exists = $t-cmd(perl -e 'print 1 if (-s \file\)') or warn
 Unable to execute command: $!\n; if ($file_exists) {
 # do whatever
 }
 
 'if (-s)' will actually check that the file has non-zero size (-s
 returns the size; if the size if 0, it is false).
 
 If you simply want to know whether it exists, but you don't care what
 size it is, then use -e.
 
 
 --Dks


You guys are the best...thx

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



Re: Cutting Variable

2003-08-17 Thread SilverFox
Jeff 'Japhy' Pinyan wrote:

 On Aug 17, SilverFox said:
 
Hi all...how can I pull the number from the given path??

/Machine4/dir/dir/dir
 
 Well, it's a little vague, but perhaps all you want is
 
   my ($num) = $path =~ /(\d+)/;
 
 Or perhaps
 
   my ($num) = $path =~ /Machine(\d+)/;
 
Cool...that did the trick

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



Net::Telnet - Variable won't change

2003-08-14 Thread SilverFox
Hey can someone help me figure out why the value of $file_exists won't 
change even when the file is mssing Thx.

#!/usr/bin/perl -w
$out=/home/laptop/scripts/perl/logs/resetmf.log;
open OUT, $out or die Unable to open $out :$!;

@site=(Machine1,Machine2);
#telnet
use Net::Telnet;
$t = new Net::Telnet (Timeout=10,
Errmode='die',
Prompt='/\$ $/i');
foreach (@site) {
$t-open($_);
$t-login('username','passwd');
print OUT scalar(localtime),  Conn EST: $_.\n;


$dir=pf/working/output/Channel_status;
@newdir=(/Machine1/$dir,/Machine2/$dir,/Machine9/$dir);

for($x=0; $x = $#newdir; $x++) {


$file_exists = $t-cmd (perl -e 'print 1 if (-s \$newdir[$x]\)') or 
warn Unable to execute: $!\n;

if ($file_exists) {
print Found it\n;
}else{
   print File Missing\n;

}
   }
 }

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



Re: Net::Telnet - Variable won't change

2003-08-14 Thread SilverFox
Jeff Westman wrote:

 
 --- SilverFox [EMAIL PROTECTED] wrote:
 Hey can someone help me figure out why the value of $file_exists won't
 change even when the file is mssing Thx.
 
 #!/usr/bin/perl -w
 $out=/home/laptop/scripts/perl/logs/resetmf.log;
 open OUT, $out or die Unable to open $out :$!;
 
 @site=(Machine1,Machine2);
 #telnet
 use Net::Telnet;
 $t = new Net::Telnet (Timeout=10,
 Errmode='die',
 Prompt='/\$ $/i');
 foreach (@site) {
 $t-open($_);
 $t-login('username','passwd');
 print OUT scalar(localtime),  Conn EST: $_.\n;
 
 
 $dir=pf/working/output/Channel_status;
 @newdir=(/Machine1/$dir,/Machine2/$dir,/Machine9/$dir);
 
 for($x=0; $x = $#newdir; $x++) {
 
 
 $file_exists = $t-cmd (perl -e 'print 1 if (-s \$newdir[$x]\)') or
 warn Unable to execute: $!\n;
 
 if ($file_exists) {
 print Found it\n;
 }else{
print File Missing\n;
 
 }
}
  }
 
 
 When I tried to run your cmd/perl line simply to test that part, I got:
 
   $file_exists = $t-cmd (ksh: syntax error: `(' unexpected
 
 Alternatively, you might try something simpler like:
 
   $file_exists = $t-cmd(test -f $newdir[$x]  print 1 || print 0);
 
 
 
 -JW
 
 
hmmmI'm still getting the same results. Think it have something to do 
with my shell (/usr/bin/sh). 

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



Net::Telnet

2003-08-14 Thread SilverFox
hey anyone know how to check if a file exists using the Telnet module?

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



File search (Help!!!!!)

2002-11-10 Thread SilverFox
Hi all, I'm looking for the best way to search/test multiple directories 
for a specific file and exec a command depending on which directory is 
missing the file. any advice?

ex:
(I'm searching for filename in the following dir)
/dir1/file/search
/dir2/file/search
/dir3/file/search/filename

command:
we need to know which directory the file was found in and exec command.

Thx in advance.

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




Re: Net::AIM error

2002-10-07 Thread SilverFox

Sanko Robinson wrote:

 Silverfox wrote...
 : hey All, am trying to use the Aim module and getting this error:
 : Code =
 : #!/usr/bin/perl -w
 :
 : use Net::AIM;
 : $aim = new Net::AIM;
 : $aim-newconn(Screenname ='anything',
 : Password ='duh',)
 : or die Error: Cannot Connect to Aim!;
 :
 : $conn = $aim-getconn();
 : $conn-set_handler('im_in', \on_im);
 :
 : print Bot loaded successfully!!\n;
 : $aim-start;
 :
 :
 : Error =
 : [laptop@localhost perl]$ ./aim.pl
 : Bot loaded successfully!!
 : Can't use an undefined value as a symbol reference at
 : /usr/lib/perl5/site_perl/5.6.1/Net/AIM/Connection.pm line 781.
 : (in cleanup) No method called handler for  object. at ./aim.pl
 : line 0
 
 You told Net::AIM to execute on_im when your bot (I'm guessing) receives
 an Instant Message even though sub on_im is undefined.
 
 You may want to define an handler for on_config and on_error. These two
 aren't managed very well by the module.
Thanks Sanko, am implementing you suggestion right now. thx for the input.

~SilverFox

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




Re: Net::AIM error

2002-10-07 Thread SilverFox

Sanko Robinson wrote:

 Silverfox wrote...
 : hey All, am trying to use the Aim module and getting this error:
 : Code =
 : #!/usr/bin/perl -w
 :
 : use Net::AIM;
 : $aim = new Net::AIM;
 : $aim-newconn(Screenname ='anything',
 : Password ='duh',)
 : or die Error: Cannot Connect to Aim!;
 :
 : $conn = $aim-getconn();
 : $conn-set_handler('im_in', \on_im);
 :
 : print Bot loaded successfully!!\n;
 : $aim-start;
 :
 :
 : Error =
 : [laptop@localhost perl]$ ./aim.pl
 : Bot loaded successfully!!
 : Can't use an undefined value as a symbol reference at
 : /usr/lib/perl5/site_perl/5.6.1/Net/AIM/Connection.pm line 781.
 : (in cleanup) No method called handler for  object. at ./aim.pl
 : line 0
 
 You told Net::AIM to execute on_im when your bot (I'm guessing) receives
 an Instant Message even though sub on_im is undefined.
 
 You may want to define an handler for on_config and on_error. These two
 aren't managed very well by the module.
OK...I rewrote the code..created the sub's..this is what am getting..any 
ideas:

ERROR:
[laptop@localhost perl]$ ./aim.pl
Including on_config.pl.. OK!
Including on_error.pl.. OK!
Including on_evil.pl.. OK!
Including on_im.pl.. OK!
Including sendim.pl.. OK!
Including commands.pl.. OK!
Including dosleep.pl.. OK!
Including log_im.pl.. OK!
Including warners.pl.. OK!
Bot loaded successfully!!

Use of uninitialized value in split at 
/usr/lib/perl5/site_perl/5.6.1/Net/AIM.pm line 702.
Can't use an undefined value as a symbol reference at 
/usr/lib/perl5/site_perl/5.6.1/Net/AIM/Connection.pm line 781.
(in cleanup) No method called handler for  object. at ./aim.pl 
line 0

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

$admin =kesthekill;

use File::Basename;
chdir(dirname($0));

#to seed random numbers
srand time;

#write admin name to file.
open (DATA, admin.txt);
print DATA $admin;
close(DATA);

#checking for needed directories.
if (-e handlers ne 1
|| -e commands ne 1
|| -e extras ne 1
|| -e logs ne 1) {
print Files are missing sucker: 
. handlers, commands, extras and logs. ;
exit;
}

#Use Net::AIM to connect to AIM
use Net::AIM;

#Setup usage of above directory/files (handlers,commands extras and log).
@dirs = (handlers,commands,extras,logs);
foreach $dir (@dirs) {
opendir(DIR, ./$dir);
foreach $file (sort(grep(!/^\./, readdir(DIR {
print Including $file..;
require $dir/$file;
print  OK!\n;
}
closedir(DIR);
}

#start a new Net::AIM instance
$aim = new Net::AIM;

#Try to connect to the AIM server.
$aim-newconn(Screenname ='kesundground',
Password ='killer',)
or die Error: Cannot Connect to Aim!;
#Net::AIM::Connection module reference
$conn = $aim-getconn();

#Set up the handlers for commands issued by the server.
$conn-set_handler('im_in', \on_im);
$conn-set_handler('error', \on_error);
$conn-set_handler('eviled', \on_evil);
$conn-set_handler('config', \on_config);


print Bot loaded successfully!!\n\n;
$aim-start;


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




Re: Net::AIM error

2002-10-07 Thread SilverFox

Silverfox wrote:

 Sanko Robinson wrote:
 
 Silverfox wrote...
 : hey All, am trying to use the Aim module and getting this error:
 : Code =
 : #!/usr/bin/perl -w
 :
 : use Net::AIM;
 : $aim = new Net::AIM;
 : $aim-newconn(Screenname ='anything',
 : Password ='duh',)
 : or die Error: Cannot Connect to Aim!;
 :
 : $conn = $aim-getconn();
 : $conn-set_handler('im_in', \on_im);
 :
 : print Bot loaded successfully!!\n;
 : $aim-start;
 :
 :
 : Error =
 : [laptop@localhost perl]$ ./aim.pl
 : Bot loaded successfully!!
 : Can't use an undefined value as a symbol reference at
 : /usr/lib/perl5/site_perl/5.6.1/Net/AIM/Connection.pm line 781.
 : (in cleanup) No method called handler for  object. at
 : ./aim.pl
 : line 0
 
 You told Net::AIM to execute on_im when your bot (I'm guessing) receives
 an Instant Message even though sub on_im is undefined.
 
 You may want to define an handler for on_config and on_error. These two
 aren't managed very well by the module.
 Thanks Sanko, am implementing you suggestion right now. thx for the input.
 
 ~SilverFox
OK...I rewrote the code..created the sub's..this is what am getting..any 
ideas:

ERROR:
[laptop@localhost perl]$ ./aim.pl
Including on_config.pl.. OK!
Including on_error.pl.. OK!
Including on_evil.pl.. OK!
Including on_im.pl.. OK!
Including sendim.pl.. OK!
Including commands.pl.. OK!
Including dosleep.pl.. OK!
Including log_im.pl.. OK!
Including warners.pl.. OK!
Bot loaded successfully!!

Use of uninitialized value in split at 
/usr/lib/perl5/site_perl/5.6.1/Net/AIM.pm line 702.
Can't use an undefined value as a symbol reference at 
/usr/lib/perl5/site_perl/5.6.1/Net/AIM/Connection.pm line 781.
(in cleanup) No method called handler for  object. at ./aim.pl 
line 0

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

$admin =iam;

use File::Basename;
chdir(dirname($0));

#to seed random numbers
srand time;

#write admin name to file.
open (DATA, admin.txt);
print DATA $admin;
close(DATA);

#checking for needed directories.
if (-e handlers ne 1
|| -e commands ne 1
|| -e extras ne 1
|| -e logs ne 1) {
print Files are missing sucker: 
. handlers, commands, extras and logs. ;
exit;
}

#Use Net::AIM to connect to AIM
use Net::AIM;

#Setup usage of above directory/files (handlers,commands extras and log).
@dirs = (handlers,commands,extras,logs);
foreach $dir (@dirs) {
opendir(DIR, ./$dir);
foreach $file (sort(grep(!/^\./, readdir(DIR {
print Including $file..;
require $dir/$file;
print  OK!\n;
}
closedir(DIR);
}

#start a new Net::AIM instance
$aim = new Net::AIM;

#Try to connect to the AIM server.
$aim-newconn(Screenname ='anything',
Password ='duh',)
or die Error: Cannot Connect to Aim!;
#Net::AIM::Connection module reference
$conn = $aim-getconn();

#Set up the handlers for commands issued by the server.
$conn-set_handler('im_in', \on_im);
$conn-set_handler('error', \on_error);
$conn-set_handler('eviled', \on_evil);
$conn-set_handler('config', \on_config);


print Bot loaded successfully!!\n\n;
$aim-start;


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




Net::AIM error

2002-10-06 Thread SilverFox

hey All, am trying to use the Aim module and getting this error:
Code = 
#!/usr/bin/perl -w

use Net::AIM;
$aim = new Net::AIM;
$aim-newconn(Screenname ='anything',
Password ='duh',)
or die Error: Cannot Connect to Aim!;

$conn = $aim-getconn();
$conn-set_handler('im_in', \on_im);

print Bot loaded successfully!!\n;
$aim-start;


Error =
[laptop@localhost perl]$ ./aim.pl
Bot loaded successfully!!
Can't use an undefined value as a symbol reference at 
/usr/lib/perl5/site_perl/5.6.1/Net/AIM/Connection.pm line 781.
(in cleanup) No method called handler for  object. at ./aim.pl 
line 0
-- 
Please reply to [EMAIL PROTECTED]

~SilverFox

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