Re: Can Perl 'nice' a process?

2005-03-04 Thread John W. Krahn
Dave Kettmann wrote:
Im sure Perl can nice a process but I guess I dont know what the correct
term is. I guess if I just start with the correct term I can discover
how to use it. Then again, I may just have to 'nice' it in the shell.
There is nothing built in to Perl that will do this.  You would have to 
either
call nice(2) through syscall() or call nice(1) or renice(8) through qx(),
system() or exec().
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: encoding script pain

2005-03-04 Thread John W. Krahn
Saurabh Singhvi wrote:
#!/usr/bin/perl -w
use strict;
opendir(DIR,".") or die "Couldn't open $!";
our @names = readdir(DIR) or die "Couldn't open $!";
closedir(DIR);
foreach my $name (@names){
if ($name =~ /avi$/) {
my $var = $name;
$var =~ s/\s/\\ /;
$var =~ s/\[/\\\[/;
$var =~ s/\]/\\\]/;
system("mencoder $var -ovc lavc -oac copy -o $var.avi");
}
}
in this script i am having a big problem.the script just ends
after the system command and returns to the shell..what could
be the reason???
This should work better:
#!/usr/bin/perl -w
use strict;
opendir DIR, '.' or die "Couldn't open '.' $!";
( my @names = readdir DIR ) or die "Couldn't read '.' $!";
closedir DIR;
foreach my $name ( @names ) {
next unless $name =~ /avi$/;
my $var = $name;
system( 'mencoder', qq("\Q$var\E"), '-ovc', 'lavc', '-oac', 'copy', '-o', 
qq("\Q$var\E.avi") ) == 0
or die "system 'mencoder' failed: $?";
}


John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: reg exp

2005-03-04 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
I have the file as attached and I want to take 104 and 356 to get a sum.
Here is my code:
while () {
if ( $. > 6 ) {
if ( $_ !~ "ANR*" or $_ !~ "ANS*" ) {
print FFF $_;
}
}
next unless $_ /^[a-zA-Z0-9]$/ {
print $_;
}
}
The pseudocode would be:  skip lines only if $_ begins with a letter and
ends with a number or visa versa,  then add 104 and 356.
OR just add 104 and 356 b/c I still need to keep all the entries as seen in
column 0.

my $total;
while (  ) {
/^\s+(\d+)$/ and $total += $1;
}
print "Total = $total\n";

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: reg exp

2005-03-04 Thread John Doe
Hello (again) Derek

Am Samstag, 5. März 2005 05.06 schrieb [EMAIL PROTECTED]:
> I have the file as attached and I want to take 104 and 356 to get a sum.
> Here is my code:
>
>
> while () {
> if ( $. > 6 ) {
> if ( $_ !~ "ANR*" or $_ !~ "ANS*" ) {
> print FFF $_;
> }
> }
> next unless $_ /^[a-zA-Z0-9]$/ {
> print $_;
> }
> }
> [...]

I would start with checking the syntax of this code first (using strict and 
warnings) to get the syntax right. 

Otherwise, you can't test the code :-)

greetings joe

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




reg exp

2005-03-04 Thread DBSMITH
I have the file as attached and I want to take 104 and 356 to get a sum.
Here is my code:


while () {
if ( $. > 6 ) {
if ( $_ !~ "ANR*" or $_ !~ "ANS*" ) {
print FFF $_;
}
}
next unless $_ /^[a-zA-Z0-9]$/ {
print $_;
}
}


The pseudocode would be:  skip lines only if $_ begins with a letter and
ends with a number or visa versa,  then add 104 and 356.
OR just add 104 and 356 b/c I still need to keep all the entries as seen in
column 0.


(See attached file: tsm2_clients.plout)

thank you ,
derek

tsm2_clients.plout
Description: Binary data
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: Net::DNS

2005-03-04 Thread DBSMITH
Because I am trying to find a way to get all the clients in a domain via
Net::DNS and see if there is an existant "object class" with Server in it.
But using Net::DNS I believe will not help b/c I think the website uses
java script.

Again, here is my problem that needs solved.  thank you,

There is this website on our internal LAN that serves as a DNS mgmt tool
and it is called qip developed by Lucent.  I know it is written in Perl but
I believe it also uses java script.

My goal is to attain all the devices that have an object class of "Server"
and an object class of pc if and only if this entry has a comment referring
to "TSM."
For now I just want to worry about getting the first one done which then
the second should come easy.

The image of the website will follow.
Can anyone provide ideas on how to attain this?  Is anyone familiar with
this mgmt tool?  I found a javscript module for perl but I am unsure if
this will even work?





   
 "JupiterHost.Net" 
 <[EMAIL PROTECTED] 
 st.net>To 
   beginners@perl.org  
 03/04/2005 06:15   cc 
 PM
   Subject 
   Re: Net::DNS
   
   
   
   
   
   





> My goal is to attain all the devices that have an object class of
"Server"
> and an object class of pc if and only if this entry has a comment
referring
> to "TSM."

What does this have to do with listing all the subdomains in a zone for
a domain liek in your other email?

i don't think anyone is able to help because you keep changing topics in
the same thread and leave out important details

i hope it works out for you

--
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: UNIX vs. Windows help

2005-03-04 Thread JupiterHost.Net

Paul Ohashi wrote:
I figured it out with a google search (google always works).
The results returned:
Also see http://search.cpan.org/~gbarr/libnet-1.19/Net/FTP.pm
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Net::DNS

2005-03-04 Thread JupiterHost.Net

My goal is to attain all the devices that have an object class of "Server"
and an object class of pc if and only if this entry has a comment referring
to "TSM."
What does this have to do with listing all the subdomains in a zone for 
a domain liek in your other email?

i don't think anyone is able to help because you keep changing topics in 
the same thread and leave out important details

i hope it works out for you
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: UNIX vs. Windows help

2005-03-04 Thread JupiterHost.Net

Paul Ohashi wrote:
Hi All,
Hello,
I moved my web server from UNIX to Windows and some things
boy talk about a downgrade :)
no longer work. I expected this to happen, but now I need
some help. Here's what worked on UNIX:
my @ftpUpList = `ftp ftp.somewhere.com <
This would put a recursive listing of my upload site in the 
array @ftpUpList and all was peachy...

Since moving the web server to windows, it fails. Does anyone
Why not use Net::FTP instead? I imagine your windows doesn't know what 
those commands are.

know what the Windows equivalent would be? All suggestions are
appreciated, thanks.
Move back off Winders ;p
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: UNIX vs. Windows help

2005-03-04 Thread Paul Ohashi
I figured it out with a google search (google always works).
The results returned:

http://www.robvanderwoude.com/index.html

Paul

-Original Message-
From: Paul Ohashi [mailto:[EMAIL PROTECTED]
Sent: Friday, March 04, 2005 1:40 PM
To: Perl List (E-mail)
Subject: UNIX vs. Windows help


Hi All,

I moved my web server from UNIX to Windows and some things 
no longer work. I expected this to happen, but now I need
some help. Here's what worked on UNIX:

my @ftpUpList = `ftp ftp.somewhere.com  



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




print to a log

2005-03-04 Thread Nishi Prafull
Hi:
I am running an external command through my perl script and I wanted
to print out the command output to some log file --

my $log = "/tmp/test.log";
my $cmd1 = qq{ ade useview viewname -exec 'ade label_product \\
-l $label -noinsert -prod dc'  -print >> $log
 };
system($cmd1);

Is the syntax correct?

Thanks.

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




writting a detailed log

2005-03-04 Thread Tim Wolak
All,
I am writtting this script for a client that will transfer their files 
via SFTP and write a small log to their system.  I would also like it to 
write a log on our server as well, other than just doing what I have, 
writting the date and the file transfered.  What can I do to capture 
erros from SFTP so that if the transfer fails I can write it to the log 
file?  Script is below:

Thanks for the help.
Tim
#Here is my rules to keep me strict
use strict;
use Net::SFTP;
#Who am I and where am I going?
my $user = 'user';
my $pass = 'password';
my $sftp;
my $home = "/home/user/test.txt";
my $path = "/home/user/test.txt";
my $host = '0.0.0.0';
#Where the real action takes place...
  $sftp = Net::SFTP->new($host, "user" => $user, "password" => $pass) 
or die "Can't login $!\n";
  $sftp->put($home,$path) || die "Can't open $!\n";

# Writting log files for transfers
#
  open LOGS, ">> cshareTransfer.log" or die "Can't open file, $!\n";
# Get my dates
#
 my $date;
 my ($sec,$min,$hour,$mday,$mon,$year) = (localtime) [0,1,2,3,4,5];
 $year=$year+1900;
 $mon=$mon+1;
 $date = sprintf("%02d%02d%02d", $year,$mon,$mday);
#
# Write my logs so I can track myself
#
 print LOGS "Transfer date:$date, File transfered:$path\n";
close LOGS;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



UNIX vs. Windows help

2005-03-04 Thread Paul Ohashi
Hi All,

I moved my web server from UNIX to Windows and some things 
no longer work. I expected this to happen, but now I need
some help. Here's what worked on UNIX:

my @ftpUpList = `ftp ftp.somewhere.com  




Re: Net::DNS

2005-03-04 Thread JupiterHost.Net

[EMAIL PROTECTED] wrote:
pshrapprd:/home/root> nslookup
Default Server:  svr
Address:  192..x.x.x

set type=a
s
Server:  svr
Address:  192..x.x.x
*** svr can't find s:Non-existent host/domain
ls
Server:  svr.*
Address:  192.x.x.x
Name:ls

?
Commands:   (identifiers are shown in uppercase, [] means optional)
NAME- print info about the host/domain NAME using default
server
NAME1 NAME2 - as above, but use NAME2 as server
help or ?   - print info on common commands
set OPTION  - set an option
all - print options, current server and host
[no]debug   - print debugging information
[no]d2  - print exhaustive debugging information
[no]defname - append domain name to each query
[no]recurse - ask for recursive answer to query
[no]vc  - always use a virtual circuit
domain=NAME - set default domain name to NAME
srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2,
etc.
root=NAME   - set root server to NAME
retry=X - set number of retries to X
timeout=X   - set initial time-out interval to X seconds
querytype=X - set query type, e.g.,
A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,W
KS,SRV,NAPTR
type=X  - synonym for querytype
class=X - set query class to one of IN(Internet),CHAOS,HESIOD or
ANY
server NAME - set default server to NAME, using current default server
lserver NAME- set default server to NAME, using initial server
finger [USER]   - finger the optional USER at the current default host
root- set current default server to the root
ls [opt] DOMAIN [>|>> FILE] - list addresses in DOMAIN(optional: output to
FILE)
-a  -  list canonical names and aliases
-h  -  list HINFO (CPU type and operating system)
-s  -  list well-known services
-d  -  list all records
-t TYPE -  list records of the given type (e.g., A,CNAME,MX, etc.)
view FILE   - sort an 'ls' output file and view it with more
exit- exit the program,^D also exits
Please don't top post, all I see are prompts, errors, and help menus I 
see no actual DNS info.

So again withotu knowing what you're tryign to do there's not muxh we 
can do to help :)

[EMAIL PROTECTED] wrote:
within nslookup you would type
nslookup "nameserver IP"
set type=ns
server "nameserver"
ls "zone"

Can you paste an actual session of that?
  a) I'm not sure how "nameserver IP" and "nameserver" in this case
  b) our network disallows lame insecure programs like nslookup so I
can't reproduce it
  c) Can't locate Telepathy.pm in @INC :)
I think you've done this enough to know you need to be more specific :)


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



RE: Hash headaches

2005-03-04 Thread Charles K. Clarkson
Terry Poperszky <[EMAIL PROTECTED]> wrote:

: Suggestions/Observations?

Don't use external commands to get directory contents.
Use 'openddir' and 'readdir' instead.


: open MYFILE, ") {
: $dir_log{chomp($_)} = 1;

'chomp' will not return a file name here. I think you
want this.

chomp;
$dir_log{$_} = 1

: }


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328






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




Can Perl 'nice' a process?

2005-03-04 Thread Dave Kettmann
Im sure Perl can nice a process but I guess I dont know what the correct term 
is. I guess if I just start with the correct term I can discover how to use it. 
Then again, I may just have to 'nice' it in the shell. Any help is appreciated.

Thanks,

Dave Kettmann
NetLogic
314-266-400
1-888-MYNETLOGIC


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




Re: Hash headaches

2005-03-04 Thread Jenda Krynicky
From:   "Terry Poperszky" <[EMAIL PROTECTED]>
> I am working on a bit of logic to be used in a script that copies new
> files to a temporary directory and I am stumped.  Basically what I
> want to accomplish is to be able to look for the existence of a file
> name in a log file, and I am trying to use a hash to accomplish this.
> 
> $directory is the listing of the current files in the directory
> 
> $dir_log currently is file containing the same information as
> $directory. 
> 
> I am trying to see if the elements of $directory exist as keys in the
> hash, but it isn't working.
> 
> open MYFILE, " 
> 
> 
> while () {
> 
> $dir_log{chomp($_)} = 1;

chomp() doesn't return what you seem to think. You have to change the 
line above to 
chomp(); $dir_log{$_} = 1;
 
Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Hash headaches

2005-03-04 Thread Terry Poperszky
I am working on a bit of logic to be used in a script that copies new files
to a temporary directory and I am stumped.  Basically what I want to
accomplish is to be able to look for the existence of a file name in a log
file, and I am trying to use a hash to accomplish this.

 

$directory is the listing of the current files in the directory

$dir_log currently is file containing the same information as $directory. 

 

I am trying to see if the elements of $directory exist as keys in the hash,
but it isn't working.

 

Suggestions/Observations?

 

 

Terry Poperszky

801-257-5709 Voice

801-924-0649 Fax

[EMAIL PROTECTED]

 

 

 

open MYFILE, ") {

$dir_log{chomp($_)} = 1;

}

 

chomp ($directory = `dir /b /O-D`);

 

foreach ($directory) {

print "success" if (exists $dir_log{$directory});

}



Re: Net::DNS

2005-03-04 Thread JupiterHost.Net

[EMAIL PROTECTED] wrote:
How would I get all hosts for a particular domain using Net::DNS?
I tried *.domainname in my query.
Do you mean how to see all the subdomains in a domain's zone file?
How would you have do that manually via CLI? (IE not using Perl or other 
custom program, just SSH into a server and run a command to get the info 
you want)

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



Re: Net::DNS

2005-03-04 Thread DBSMITH
How would I get all hosts for a particular domain using Net::DNS?
I tried *.domainname in my query.


thanks,



   
 "Wiggins  
 d'Anconia"
 <[EMAIL PROTECTED]  To 
 .org> [EMAIL PROTECTED]
cc 
 03/02/2005 09:15  beginners@perl.org  
 AMSubject 
   Re: Net::DNS
   
   
   
   
   
   




John Doe wrote:
> Hi Derek,
> hi all (see below, please help)
>
>
>>[...]
>>
>>>my $res = Net::DNS::Resolver->new;
>>>my $query = $res->query(".ohnet", "NS");
>>>
>>>
>>>if ( $query != 0 or $query != undef or $query != ' ' )  {
>
>
> Please replace this condition by
>
> if ($query)
>
> I'm to confused at the moment to explain why in detail, sorry...
>

Your question below answers why.

>
> ==
>
> hi all
>
> while trying to prove by code that the above if condition is incorrect...
>
>My logic says that a condition in the form
>if ($a != $val1 or $a != $val2)
>is always true.

Unless both are false which is a basic premise of 'or'.

>
>sub test {print "condition is true\n" if $_[0] != 1 or $_[0] != 2}
>test (1);   test (2);   test (3);
># this prints 3 times as expected:
>condition is true
>
> ... I struggled over something when I included "undef" in some code
tests:
>
>print "Oups!\n" if 0==undef;
># prints:
>Oups! #  ?
>
> Can anybody please explain this result to me.
>
>print "Oups!\n" if !defined 0;
># prints nothing as expected.
>

The key here is that the == and != operators put their operands into
numerical context. 'undef' in numerical context resolves to 0. So the
first case is true.  In the second case you are *specifically* checking
for definedness (not matching a value), and 0 *is* defined.

>
> I thought that a had a clue of perl after using it intensively for years.
> I'm not shure anymore...
>

Understanding undefined vs. true/false vs. 0 vs. some other value is
definitely a difficult thing to grasp and unusual to HLLs where context
can automagically switch values.

So back to your confusion above, you want to check,

if ($query)

Because 'undef' resolves to false. However, if $query could contain a
false value (namely 0) then you would have to check specifically for
undefinedness,

if (defined $query)

and this becomes a nasty bug when not being paid special attention, but
is also one reason why turning of initialization warnings is often a bad
idea.

Just to blow your mind, look around for "zero but true" ;-)

>
>
> greetings joe
>

http://danconia.org

--
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]
 




Establishing a TLS connection to a LDAP server

2005-03-04 Thread Aurelien Magniez
Hi,

I've read a great article about connecting securely to
LDAP using PHP
(http://www.novell.com/coolsolutions/trench/5838.html).
It works nice :-)

I would like now to authenticate the both sides when
establishing the TLS tunnel. In other words, my
OpenLDAP requires a client certificate.

After searching many hours and trying different
solutions (ldap.conf, environment variables...), I
still have the same problem : the client certificate
isn't sent by my apache server :-((

Do you have any idea in order to solve it ?

Thanks in advance,

Best Regards,

Aurelien






Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails ! 
Créez votre Yahoo! Mail sur http://fr.mail.yahoo.com/

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




RE: Defined revisited

2005-03-04 Thread Larsen, Errin M HMMA/IT
> Sorry to bother you, since I notice other people have also 
> been asking 
> about defined.  But the answers to their questions have not 
> helped me to 
> this point.

  No problem.  That's what we're here for.  As long as you've put in the
time to try to solve the problem yourself (which it looks like you've
done), you're not bothering anyone!

> 
> This morning I started seeing a vague, unhelpful warning 
> message about an 
> undefined variable from a program after months of successful 
> use.  The 
> warning occurs in a test line of the form
> 
> if ($xx > $yy) {
> 
> So I 
> 
>   1.  Checked the input data visually.
> 
>   2.  Checked the data again by going through the algorithm, 
>using the actual data in the input files.
> 
>   3.  Added print statements for $xx and $yy.
> 


  What did you see when you printed $yy?


> Finding nothing wrong, I created the following test program 
> containing the 
> essential logic, and with a variable deliberately undefined.
> 

  What are you really trying to fix.  Did the logic of your code break?
Or are you merely concerned with the warning message?  Perl is only
doing what you asked it to do.  By using the 'warnings' pragma, you've
specifically asked Perl to warn you when you use a variable that has not
been defined yet.  To remove the warning message, remove the "use
warnings;" line from your code!
  However, the warning is valuable.  You are probably assuming that $yy
== 0, which it most certainly is not.  It is "undefined".  If you want
your code to assume that this ($yy) variable is zero when it is
undefined, why not put in a test and change it to zero if it is
"undefined"?

  $yy = 0 unless( defined $yy );

> ==
> use strict;
> use warnings;
> use diagnostics;
>
> my $xx = 7;
> my $yy;
>
> if ($xx > $yy) {
> print "xx > yy, so do stuff\n";
> } else {
> print "Do not do stuff\n";
> }
> ==

  <>

> ==
> use strict;
> use warnings;
> use diagnostics;
> 
> my $xx = 7;
> my $yy;
> 
> if ((defined $yy) == 0) {


  by the way, this is easier to say like this:
   if (!defined $yy)
  or better yet:
   unless( defined $yy )


> print "\nyy is NOT defined, so Exit\n";
> exit;
> }
> 
> if ((defined $xx) == 0) {
> print "\nxx is NOT defined, so Exit\n";
> exit;
> }
> 
> if ($xx > $yy) {
> print "xx > yy, so do stuff\n";
> } else {
> print "Do not do stuff\n";
> }
> ==

> 
> In the test program, this fixed the problem, as did several 
> other versions 
> of the tests.  

  What problem was solved?  I'm confused here.

> So I added the tests to the real program, 
> intending to add 
> a bunch of print statements before "exit" so I could analyze the 
> underlying problem.  Unfortunately, the tests using "defined $yy" and 
> "defined $xx" failed in the real program:  absolutely no change in 
> behavior, except that the line number printed by the warning message 
> increased to allow for the test code.  I tried a whole bunch 
> of tests, and 
> every single one of them failed.
> 
> What have I missed?
> 
> Thanks,
> Walt
> 
> -- 

Hope to help! 

--Errin

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




Re: RedHat, ttyS0 and perl

2005-03-04 Thread Wiggins d'Anconia
Giff Hammar wrote:
I am writing a small perl program that takes the serial output from our phone
switch and puts the individual call records into a Postgres database. Everything
works except for the part where I have to open the serial port. I am on RedHat
EL 4 and perl 5.8.5. The serial port is /dev/ttyS0, which I know works from the
OS level. 

I tried
open(PORT,"+>/dev/ttyS0") or die "Couldn't open serial port\n";
Try adding $! to the error string to see why it is failing, I assume it 
is dieing.

but that didn't work. I'm missing something, but I can't quite put my finger on
what.
Giff
Conveniently I am trying to get a modem working, which is 
inconsequential, but I ran across this script earlier today that might 
prove useful somehow:

http://axion.physics.ubc.ca/modem-chk.html
It is at least an example of how to talk to a serial port
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RedHat, ttyS0 and perl

2005-03-04 Thread Giff Hammar
I am writing a small perl program that takes the serial output from our phone
switch and puts the individual call records into a Postgres database. Everything
works except for the part where I have to open the serial port. I am on RedHat
EL 4 and perl 5.8.5. The serial port is /dev/ttyS0, which I know works from the
OS level. 

I tried

open(PORT,"+>/dev/ttyS0") or die "Couldn't open serial port\n";

but that didn't work. I'm missing something, but I can't quite put my finger on
what.

Giff

Giff Hammar [EMAIL PROTECTED]
IT Director
Certified Parts Warehouse
V: 603.772.8870 F: 603.778.6931
http://www.certifiedparts.com



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




Re: encoding script pain

2005-03-04 Thread Vladimir D Belousov
First, your regext could be
 $var =~ s/[\s\[\]]/\\$1/g;
Next, you should use two arguments style "system" calls:
system("/usr/local/bin/programm", args);
Third, you have to analyze a return code of a "system" command:
my $status = system(...);
print "Error [errno = $status]\n" if($status);
Saurabh Singhvi wrote:
#!/usr/bin/perl -w
use strict;
opendir(DIR,".") or die "Couldn't open $!";
our @names = readdir(DIR) or die "Couldn't open $!";
closedir(DIR);
foreach my $name (@names){
   if ($name =~ /avi$/) {
   my $var = $name;
   $var =~ s/\s/\\ /;
   $var =~ s/\[/\\\[/;
   $var =~ s/\]/\\\]/;
   system("mencoder $var -ovc lavc -oac copy -o $var.avi");
   }
}
in this script i am having a big problem.the script just ends
after the system command and returns to the shell..what could
be the reason???
some1 plz help me 

thnx in adv
Saurabh
 


--
Vladimir D Belousov
HiTech solutions for business
http://businessreklama.ru
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Net::DNS

2005-03-04 Thread John Doe
Hello Derek

Am Mittwoch, 2. März 2005 17.19 schrieb [EMAIL PROTECTED]:
> [...]
> > btw: If the 1st FOR LOOP loop failed, @a is empty, so maybe you should
> > move the last 3 lines in the 1st FOR LOOP  if branch.
>
>   tkx for the pointer!  So here is what you mean?
>
>
> foreach ($query->answer) {
>  if ( $_->type eq 'NS' ) {
>  #next unless $_->type eq "A";
>  foreach ($_->nsdname) {
>  push (@a,$_) if $_ =~ "svr";
>  $e++;
>  } # END 2nd FOR LOOP
>  } else {
>  print F "DNS query failed: ", $res->errorstring, "\n";
>  } # END 2nd IF
>
>   @a = sort { $a cmp $b } @a;
>   print F $a[0],"\n";
>   print F $a[1],"\n";
>  } # END 1st FOR LOOP
>
>  } # END 1st IF

No, I meant something like the following to catch the case where @a is not 
filled with any values:

> if ( $query != 0 or $query != undef or $query != ' ' )  {
> foreach ($query->answer) {
> if ( $_->type eq 'NS' ) {
> #next unless $_->type eq "A";
> foreach ($_->nsdname) {
> push (@a,$_) if $_ =~ "svr"; # fill @a
> $e++;
> } # END 2nd FOR LOOP
> } else {
>print F "DNS query failed: ", $res->errorstring, \n";
> } # END 2nd IF
> } # END 1st FOR LOOP
+if (@a) {
+ @a = sort { $a cmp $b } @a;
+ print F $a[0],"\n", $a[1],"\n";
+}
> } # END 1st IF
- @a = sort { $a cmp $b } @a;
- print F $a[0],"\n";
- print F $a[1],"\n";

if the 1st IF branch is not visited, @a is always empty;
if it is visited, @a _may_ be filled with values

:-)

greetings joe

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




Re: Net::DNS

2005-03-04 Thread John Doe
Hello

Thanks much for your answer

Am Mittwoch, 2. März 2005 15.15 schrieb Wiggins d'Anconia:
> John Doe wrote:
> [...]
> >My logic says that a condition in the form
> >if ($a != $val1 or $a != $val2)
> >is always true.
>
> Unless both are false which is a basic premise of 'or'.

I implicitly included the condition $val!=$val2, sorry for that...

> >[...]
> >print "Oups!\n" if 0==undef;
> ># prints:
> >Oups! #  ?
> >
> > Can anybody please explain this result to me.
> >[...]
>
> The key here is that the == and != operators put their operands into
> numerical context. 'undef' in numerical context resolves to 0. So the
> first case is true. 

Aaarrggghhh! Thanks alot!

> [...]

greetings joe

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




Re: call a perl script within another perl script

2005-03-04 Thread Chris Devers
On Thu, 3 Mar 2005, Nishi Prafull wrote:

> I would like to call a perl script(B.pl) within another perl script 
> (A.pl). Should I use the following approach or something else?
> 
> A.pl
> -
> my $cmd = "perl B.pl"
> system($cmd);
> 
> Please let me know.

Is there a reason that A.pl can't just say

  require "B.pl";

?

 

-- 
Chris Devers

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




encoding script pain

2005-03-04 Thread Saurabh Singhvi
#!/usr/bin/perl -w
use strict;

opendir(DIR,".") or die "Couldn't open $!";
our @names = readdir(DIR) or die "Couldn't open $!";
closedir(DIR);

foreach my $name (@names){
if ($name =~ /avi$/) {
my $var = $name;
$var =~ s/\s/\\ /;
$var =~ s/\[/\\\[/;
$var =~ s/\]/\\\]/;
system("mencoder $var -ovc lavc -oac copy -o $var.avi");
}
}


in this script i am having a big problem.the script just ends
after the system command and returns to the shell..what could
be the reason???

some1 plz help me 

thnx in adv
Saurabh

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




Re: setting program priority by PID

2005-03-04 Thread Ing. Branislav Gerzo
Bakken, Luke [BL], on Thursday, March 3, 2005 at 09:26 (-0800) wrote
these comments:

BL> Use Win32::Process:
BL> http://search.cpan.org/~jdb/libwin32-0.24/Process/Process.pm

thanks, now I can set priority of running program:

use strict;
use warnings;
use Win32::Process::Info;
use Win32::Process;
use Win32;

my $pi = Win32::Process::Info->new();

for my $x ( $pi->GetProcInfo() ) { 
if ( $x->{Name} =~ /program_name/i ) {
my $po;
Win32::Process::Open($po,$x->{ProcessId},0) || die "Error\n";
$po->SetPriorityClass(IDLE_PRIORITY_CLASS);
exit;
}
}

Perl is amazing...:)

-- 

 ...m8s, cu l8r, Brano.

[Don't just do something, stand there.]



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