Re: How To Integrate

2001-08-29 Thread Daniel

"Satish" <[EMAIL PROTECTED]> wrote:

> I am a beginner to perl.
> but i have woked in java.
> now i would like to know how to intergrate these two

Check out Inline::Java
http://search.cpan.org/search?dist=Inline-Java

-D


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




CPAN

2005-01-10 Thread Daniel
I made a mistake when setting up CPAN, I chose Central America as my
Continent, then the only option was to chose Costa Rica as my Country.
 Not that I have anything against Costa Rica, very lovely place will
visit soon, but would like a ftp server closer to my real home.  I
looked thru the h option and the perldocs, but cannot figure out how
to reload my info.  Please help!!

Daniel

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




Re: CPAN

2005-01-10 Thread Daniel
Thanks all worked like a charm!

Daniel


On Tue, 11 Jan 2005 00:42:02 -0500, Scott R. Godin <[EMAIL PROTECTED]> wrote:
> Daniel wrote:
> > I made a mistake when setting up CPAN, I chose Central America as my
> > Continent, then the only option was to chose Costa Rica as my Country.
> >  Not that I have anything against Costa Rica, very lovely place will
> > visit soon, but would like a ftp server closer to my real home.  I
> > looked thru the h option and the perldocs, but cannot figure out how
> > to reload my info.  Please help!!
> >
> > Daniel
> 
> fire up the cpan shell and enter
> 
>o conf init
> 
> at the cpan> prompt (yes that's the letter o, not a bullet point)
> 
> --
> Scott R. Godin
> Laughing Dragon Services
> www.webdragon.net
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
>

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




how to add .h files to .xs

2007-11-19 Thread Daniel
Hi,

I am handling a project needing to call DLL by perl. I wrote the core
code in C++ and I want to call these classes and functions in .xs.
However, I don't know how to achieve this...
First of all, I must include .h files in .xs, so I should add .h files
in the same directory as .xs. I want to ask, apart from .h files, what
other files need I include? such as cpp, lib or others?

Thank you very much!!

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




sleep under windows cmd

2004-02-22 Thread daniel
Hi helpers,

I'm very new in perl programming(in programming at all acutally) and
wondering about the following piece of code which I was running under
W2K command-line:
print "First";
sleep 2;
print "Second";
I thought the script would print First then wait for 2 seconds and than 
print Second. But the script ist waiting 2 seconds first and than it 
print FirstSecond 

Thanks for your help.

d a n i e l



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



\r -Option

2004-02-23 Thread daniel
Hi Guys,

I'm running the following code under w2k command-line:

$| = 1; #Autoflush
print "Test\r";
sleep 2;
print "OK";
and the output is

OKst

Eh, how can I delete the whole privious print output 

Thanks a lot...

... and all you helpful guys what you are doing is great and
you have my full respect :-)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Getting Perl to interact with passwd

2001-06-11 Thread Daniel Ames

Hi all,

This was brought up before, but the archives didn't really answer my
question.

I'm trying to get my script to reset a password for me via the passwd
command. Keep in mind, I'm very new, so if this is dumb, try not to laugh:

#!/usr/bin/perl

open(handle, "| passwd joeuser");

print handle "password\n";
print handle "password\n";
close(handle);

Here's what it spits out:

Changing password for user joeuser
New UNIX password: Retype new UNIX password:
New UNIX password:
New UNIX password:
passwd: Conversation error

Then it dies. I know I'm doing this wrong. Any ideas?

Thanks!




RE: Getting Perl to interact with passwd

2001-06-11 Thread Daniel Ames

At 01:14 PM 6/11/01 -0700, Paul wrote:
> > #!/usr/bin/perl
> >
> > open(handle, "| passwd joeuser");
> >
> > print handle "password\n";
> > print handle "password\n";
> > close(handle);
> >
> > Here's what it spits out:
> >
> > Changing password for user joeuser
> > New UNIX password: Retype new UNIX password:
> > New UNIX password:
> > New UNIX password:
> > passwd: Conversation error
> >
> > Then it dies. I know I'm doing this wrong. Any ideas?
> >
> > Thanks!
>
>WARNING: *STRICTLY* SPECULATION! =o)
>
>
>
>  maybe passwd is actually reading directly from the terminal, rather
>than just from stdin? You might end up having to fork a process and
>write to `tty`. Hope not, but it's possible.

Check the man page for your passwd, it might have an entry like this:

--stdin
   This option is used to indicate that passwd  should
   read  the  new  password from standard input, which
   can be a pipe.

There again, when I try it, I get a message that

$ passwd --stdin
Only root can do that

But maybe you *are* root...

Otherwise, you're going to need something like Expect.pm.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com
-

Awesome! That worked! Thanks Peter! ^_^

Daniel



RE: Getting Perl to interact with passwd

2001-06-12 Thread Daniel Ames

On Tue, 12 Jun 2001, Paul wrote:
> --- Daniel Ames <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > This was brought up before, but the archives didn't really answer my
> > question.
> >
> > I'm trying to get my script to reset a password for me via the passwd
> > command. Keep in mind, I'm very new, so if this is dumb, try not to
> > laugh:
> >
> > #!/usr/bin/perl
> >
> > open(handle, "| passwd joeuser");
> >
> > print handle "password\n";
> > print handle "password\n";
> > close(handle);
> >
> > Here's what it spits out:
> >
> > Changing password for user joeuser
> > New UNIX password: Retype new UNIX password:
> > New UNIX password:
> > New UNIX password:
> > passwd: Conversation error
> >
> > Then it dies. I know I'm doing this wrong. Any ideas?
> >
> > Thanks!
>
> WARNING: *STRICTLY* SPECULATION! =o)
>
> 
>
>  maybe passwd is actually reading directly from the terminal, rather
> than just from stdin? You might end up having to fork a process and
> write to `tty`. Hope not, but it's possible.
>
> 
>
> List?

i distinctly remember reading something to that effect. the passwd program
must
be reading from the controlling terminal /dev/tty. if so the correct way to
implement this entirely in perl would be to set up a pair of pseudo
terminals,
fork a process, have the child make the slave pseudo terminal a controlling
terminal and spawn passwd.

/kk

p.s. i believe that is what expect does, but in a general sort of way
----
---
just for the record, here's how I got it to work...

#!/usr/bin/perl

open(handle, "| passwd --stdin joeuser");

print handle "password\n";

close(handle);

This works great! Thanks again, Peter!

Daniel




Re: Confused

2001-07-04 Thread Daniel Dwyer

> A friend of mine sent me a file to write
>   to help get me started on programming Perl.
> So I did (in notepad):
> 
> #!/usr/bin/perl -w
> use strict;
> while (<>) {
> if ( /book/i or /bk/i) {
> print;
> }
> Missing right curly or square bracket at findit.pl line 6, at end of line
> syntax error at findit.pl line 6, at EOF
> Execution of findit.pl aborted due to compilation errors.
> 

You need to close your while loop.
It should be like this

 #!/usr/bin/perl -w
 use strict;
 while (<>) {
 if ( /book/i or /bk/i) {
 print;
 }
}#missing this one

-D





Truth and SQL

2001-07-17 Thread Daniel Falkenberg

Hi list,

Basically I want to be able to do an SQL query and if the query returns no
results I want my script to say Ok your query rerurned 0 results print this
message... "Sorry your seach returned no messages".

What is my best way of going about this? Would it work similar to this...

Do search 

if (!$sql_search) {
print "Sorry your result returned no matches"';
else {
print "here are the results";
 $sql_search;
}
}

Any suggestions will help imensly,

Regards,

df


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




RE: Hyperlink to parse on SQL column entries.

2001-07-18 Thread Daniel Falkenberg

>  
> List,
> 
>  face="Verdana" size="3" color="#0155B1">$entries->{unique_id}
>   -   color="#0155B1">$entries->{fname}
> $entries->{lname}(input type="hidden" value=$)
> 
> 
> The following Hyperlink in my HTML is incorperated in my perl script.  I
> want this hyperlink to parse to another sub and then also parse on things
> like $entries->{unique_id}... the unique_id of coarse in the new sub.  I
> can do this with the user selecting certain radio or check boxes and then
> parse on the resuls to another sub.
> 
> Is this possible with hyperlinks?
> 
> Regards,
> 
> Daniel Falkenberg

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




Is it Perl or my Web Server?

2001-07-23 Thread Daniel Falkenberg

List,

I have an interesting problem here...

Basically I could change one small section in my script such as the width of
a table such as...

print<
HTML

I will change the 600 to 604 then save my script and run it again.  When I
go to view it in a browser I get an internal server error.  There is no
reports of anything going wrong as I have checked all my logs.  Does any one
have any ideas as to why this is happeneing.  I am using apache/squid on my
linux redhad 7.1 box and using IE.5.5 as the client browser.

Any ideas will help...

Regards,

Daniel Falkenberg



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




OT - PostgreSQL

2001-07-24 Thread Daniel Falkenberg

List,

Can some one please tell me how I would go about sorting a column using
PostgreSQL. I have a columnn that contains four entries...

1 - PENDING
2 - INCOMPLETE
3 - COMPLETE
4 - DELETED

I need to sort this column by first DELETED --> then INCOMPLETE --> then
COMPLETE --> then DELETED

Any ideas on how to do this?

Thanks in advance!

Daniel Falkenberg

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




OT - PostgreSQL

2001-07-24 Thread Daniel Falkenberg

List,

Can some one please tell me how I would go about sorting a column using
PostgreSQL. I have a columnn that contains four entries...

1 - PENDING
2 - INCOMPLETE
3 - COMPLETE
4 - DELETED

I need to sort this column by first DELETED --> then INCOMPLETE --> then
COMPLETE --> then DELETED

Any ideas on how to do this?

Thanks in advance!

Daniel Falkenberg


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




Running Perl scripts...

2001-07-24 Thread Daniel Falkenberg

List,

I want to be able to check for errors on my Linux box before I run them in a
browser.  The problem is is tha when I do this all my HTML is dispalyed.  I
don't want to see this I want to be able to just check for any errors and
display the errors only.

Can I run them with out print what is between my 

print<


Re: No "make", "nmake", or "dmake" in build 628 of ActivePerl for Win32?

2001-07-24 Thread Daniel Dwyer

"Bob Abugov" <[EMAIL PROTECTED]> wrote:

> Hi, I'm trying to build modules on a Win2K system using the Perl make
>command. What do I need to do? When I try to use it after building a
>Makefile, Perl can't seem to find here's what I get:
>

Use activestates PPM.
Read more about it here.
http://aspn.activestate.com/ASPN/Products/ActivePerl/faq/ActivePerl-faq2.htm
l

-D


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




Re: Date verification

2001-07-25 Thread Daniel Grossman

Mark Byerley wrote:
> 
> Good Morning/Afternoon to all
> 
> I need some error checking (or rather field validation) within my script
> itself to ensure a date field coming across on a form is in the format of
> dd-mm-. I would rather not have to strip the field down to check the
> individual numbers and then put them back together again. Is there any
> "simple" type of error checking I can use in this instance? I appreciate the
> help.
> Thank you
> M~

How about pattern matching?

if ($theDate !~ m/\b(0[1-9]|[1-2][0-9]|3[01])-(0[1-9]|1[0-2])-\d{4}\b/)
{
reject ...
} else {
celebrate ...
}

Note that my year validation is somewhat less robust than my month and
day validation. :-)

Daniel

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




DROP DOWN BOXEN

2001-07-25 Thread Daniel Falkenberg

List,

I would like the following HTML/PERL sub. to go forth and grab all the users
from my database and place them into a drop down box.  Problem is I am
getting information allover the page everywhere? Could some give me some
hints on how to grab information from a database and display this
information in a drop downbox correctly?

Regards,

Daniel Falkenberg

sub add_job{
 my $sth = $dbh ->prepare( qq{ SELECT username FROM
db_users
   } ) || die $dbh->errstr; ;
$sth->execute;
my $entries;
print<


HTML
while ($entries= $sth->fetchrow_hashref){
print<{username}
HTML
print<

HTML
}
}

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




Another pattern question

2001-07-26 Thread Daniel Mester

Hi again,
 for example i have a file like :
zxcvzxcv
qwerasdf
bnmmsdfgy

I need to split the sentences into a variables in list. So i do it in 2
stages:
1. Remove the \t form each pair:
foreach (@list) { push(@temp, (split(/\t+/, $_))); }

2. Then i remove the \n between the strings:
foreach (@temp) { push(@temp2, (split(/\n/, $-))); }

I am wondering - is there a way to do it in one turn? Must be, no?

Daniel.


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




UNIQUE ID problems...

2001-07-26 Thread Daniel Falkenberg

List,

Interesting problem that I think proves just how much I really don't know
about Perl.

I have copyied most of this variable from the internet... 

my $unique_id  = time && 0xF && $$;

 ALL I know is that this uses Unix time and some sort of process ID and also
adds some other magic stuff to it.  My question is is... I use this exact
same variable in another script that inserts $unique_id into a row on a
database.  As I mentioned the variable is used in two scripts and inserts
the variable value into the same table in the database. Will this varibale
ever be the same? (STUPID QUESTION)? The column where this unique_id is
inserted is also the primary key so I will never have to worry about this
being the same in the database.  But if it is the unique_id will not be
inserted in the database and therefore the entire INSERT will not work.

HOPE THIS MAKES SENSE...

Regards,

Daniel Falkenberg



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




Explaining myself correctly RE: SORTING BY DATE

2001-08-06 Thread Daniel Falkenberg

List,

Please accept my sicerest apologies for not explaining myself correctly in
my last post (RE: SORTING BY DATE).

What I really need to be able to do is have my script display the date as
YEAR () MONTH (xx) DAY (xx)

For egsamle todays date would be displayed as 20010807 

At the moment I can display the date as 7/8/2001 but I really need the zeros
in there and displayed as year first.  The code for this is as follows...

my $lt= localtime;
my $date_added = $lt->mday . '/' . ($lt->mon + 1) . '/' . ($lt->year +
1900);

Any ideas?

Kind Regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




PERL and HTML question...

2001-08-06 Thread Daniel Falkenberg

Dear List,

print<
HELLO WOLRD!

HTML

If this HTML is being run with Perl which it is of coarse how would I know
what version of the HTML it is.

I really hope this makes sense.  I read there is alot of different versions
of HTML such as 3.2 and 4.0.  Does the browser take care of this?

Regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




DBI Perl and rows...

2001-08-07 Thread Daniel Falkenberg

List,

I have the following code here

my $sth = $dbh ->prepare( qq{ SELECT * FROM
table_name
WHERE status <> 'DELETED' AND status <>
'COMPLETE'
ORDER BY status
   } ) || die $dbh->errstr; ;
  $sth->execute;
  my $entries;
  my $truth = $sth->rows;
  if ($truth == 0 ){
print<= 1 ){
print

Displaying 10 jobs per page worries...

2001-08-12 Thread Daniel Falkenberg

Dear list,

The following sub will create a hyperlink when the amount of jobs in my
PostgreSQL database reaches over 10 jobs.  The hyperlink is a Perl sub which
shows the next amount of jobs in the database.  I want to only show the next
10 and then the next 10 and for arguments sake the next 3.  There for having
a total of 33 rows in that query.  Is the following code an extremly long
way of doing this.  It is not very efficient either.  

Does any one have any ideas on how I would go about doing this in an easier
and more scaliable fasion?...

sub show_all{
  my $sth = $dbh ->prepare( qq{ SELECT * FROM
table
WHERE status <> 'DELETED' AND status <>
'COMPLETE'
ORDER BY status_sort
   } ) || die $dbh->errstr; ;
  $sth->execute;
  my $entries;
  my $truth = $sth->rows;
  if ($truth == 0 ){
  print<= 1 ){
  $sth = $dbh ->prepare( qq{ SELECT * FROM
table
WHERE status <> 'DELETED' AND status <>
'COMPLETE'
ORDER BY status_sort LIMIT 10
   } ) || die $dbh->errstr; ;
  $sth->execute;
  print<fetchrow_hashref){
  print<



HTML
   my $select  = qq();
   print<$entries->{unique_id}
 - 
$entries->{status}
- $entries->{fname}
$entries->{lname}

Message:
$entries->{message}
Details: $entries->{date_added}

$entries->{time_added}

HTML
}
if ($truth > 10 ){ # If there are more than 10 jobs in the
database the page creates this hyperlink whici
   # points to another hyperlink(PERL SUB).
This dispalys the next amount of jobs in the database,
print<


http://mysite.com/cgi-bin/script.cgi?action=z_jobs";
style="color: #99; font-size: 8pt; font-weight: bold">|NEXT xx
JOBS|

HTML
}
  }
}

Kind Regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




test

2001-08-14 Thread Daniel Falkenberg

test

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Calculation the total of my column

2001-08-15 Thread Daniel Falkenberg

List,

I have a problem here that I am having a little bit of trouble trying to
resolve.  Firstly I have a Perl script that connects to a PostgreSQL
database using the DBI module.  I want to be able to SELECT a column from
the database and return the total result.  

For example if I do the following...

$sth = $dbh ->prepare( qq{   SELECT  minutes
   FROMtable
   WHERE   status = 'COMPLETE'
   } ) || die $dbh->errstr; ;
$sth->execute;

The minutes attribute is of type integer.  I want to be able to calculate
the total for the attribue minutes.  So far the result for the SQL query
above is...

minutes

   30
   45
5
5
   15
   25
   15
5
   25
   25   
(10 rows)


How would I with Perl now count the column above and return a result?

Any ideas would help imensly.

kind regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




(Answer to my own question) RE: Calculation the total of my column

2001-08-15 Thread Daniel Falkenberg

Dan, :)

$sth = $dbh ->prepare( qq{   SELECT SUM(time_track_minutes) 
   FROM table
 WHERE  status = 'COMPLETE'
   } ) || die $dbh->errstr; ;
$sth->execute;

Regards,

Daniel Falkenberg


List,

I have a problem here that I am having a little bit of trouble trying to
resolve.  Firstly I have a Perl script that connects to a PostgreSQL
database using the DBI module.  I want to be able to SELECT a column from
the database and return the total result.  

For example if I do the following...

$sth = $dbh ->prepare( qq{   SELECT  minutes
   FROMtable
   WHERE   status = 'COMPLETE'
   } ) || die $dbh->errstr; ;
$sth->execute;

The minutes attribute is of type integer.  I want to be able to calculate
the total for the attribue minutes.  So far the result for the SQL query
above is...

minutes

   30
   45
5
5
   15
   25
   15
5
   25
   25   
(10 rows)


How would I with Perl now count the column above and return a result?

Any ideas would help imensly.

kind regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




System calls?

2001-08-16 Thread Daniel Mester

Hello all,
i need to get some system data from Windows 2000 as number of currently
opened sockets, running threads, handles and processes - what is the best
way to do it?
Thanks.
Daniel.


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




Graphing with PERL and HTML

2001-08-16 Thread Daniel Falkenberg

Dear list,

Has any one here worked with Perl and HTML to draw graphs on a web page?
Is there a module I can use to write these graphs.  I am im very
unfamilier ground here.  Any ideas or input would be greatly
appriciated.

For everyone that wants to see some code :)...

sub statistics{
 my $sth = $dbh ->prepare( qq{   SELECT SUM(time_track_minutes)
 FROM   table
 WHERE  status = 'COMPLETE'
   } ) || die $dbh->errstr; ;
  $sth->execute;
  my $entries= $sth->fetchrow_hashref;
  my $one = ($entries->{sum}/60); #hours
  my $rounded = sprintf("%.0d",$one);
  my $true = ($rounded * 60 );
  my $true2 = ($entries->{sum} - $true);

print

What does this error actually mean?

2001-08-16 Thread Daniel Falkenberg

List,

I have always wondered what this error actually means.  Would it be
possible for some one to give me a quick run down on what is happeneing
when the error occures?  I am really interested in the called to early
part of the line...

called too early to check prototype at
/usr/lib/perl5/site_perl/5.6.0/GD/Graph/Map.pm line 366

Regards,

Daniel Falkenberg


==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Perl Daemons

2001-08-31 Thread Daniel Falkenberg

List,

I have the following code that I ran on my UNIX system but because I am
inexperienced with Perl I don't actually know if the Damon has stopped
running.  I closed the TTY I was running it on but if I do a ps aux on
my system it tells me I am still running the damon script?  How do I go
about stopping this script...

Regards,

Daniel Falkenberg

#!/usr/bin/perl -w

#Testing daemons

use POSIX qw(setsid);

chdir '/' or die "Can't chdir to /: $!";
umask 0;
open STDIN, '/dev/null'   or die "Can't read /dev/null: $!";
#open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork)   or die "Can't fork: $!";
exit if $pid;
setsidor die "Can't start a new session: $!";

while(1) {
   sleep(5);
   print "Hello...\n";
}

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Killing a deamon

2001-09-03 Thread Daniel Falkenberg

List,

Is there a quiker way to restart a perl daemon in UNIX rather than
having to do a kill -9 PID then start the service again using
./name_of_file.pl.  Is there any easy way like restarting the httpd
daemon service httpd restart?

Kind Regards,

Daniel Falkenberg

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 4 September 2001 12:02 PM
To: peter grotz
Cc: [EMAIL PROTECTED]
Subject: Re: creating a daemon


There is a big section in the Perl Cookbook( O'Reilly) that show you
step
by step detail of how to create a daemon.



peter grotz wrote:

> hi all,
> I need a program to run like a daemon. it should do:
> look in a directory for some flag-files, if  some exist the daemon
> should start other programs, then the daemon should sleep for let´s
say
> 5 seconds and begin again...
> how must I create such a daemon and how can I stop him working with a
> small script.
> excuse me for this newbie-questions
> thanks
>
> --
> peter grotz
>
> rehberger architekten
> schertlinstr 23
> 86 159 augsburg
>
> tel 0821 25980-29
> fax 0821 25980-20
>
> --
> 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]


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




RE: FileCache - use strict

2001-04-30 Thread Cron, Daniel


Thanks!

I'm not sure I understand, though.

I'm trying to write to file 'a01file' which is represented by file handle
$a01.
The info I'm trying to write is "XYZ\n".

I think your solution writes to standard out, not file a01file.
I'm probably still missing something.

Thanks again!

-Original Message-
From:   Johnathan Kupferer [mailto:[EMAIL PROTECTED]]
Sent:   Monday, April 30, 2001 4:34 PM
To: Cron, Daniel
Cc: '[EMAIL PROTECTED]'
Subject:Re: FileCache - use strict

The error is a bit misleading.  The problem is you need an
operator 
between $ao1 and "XYZ\n".  Try:

print $a01, "XYZ\n";

or

print $a01 . "XYZ\n";

This should clear things up.  I don't know whay perl is
trying to do with it if you don't "use strict"...

- Johnathan

> 
> How can I fix this so it will work with "use strict;"?
> (The program is really a few hundred lines long and
growing. I find having
> "use strict;" on helps me catch a lot of bugs during
development.)
> 
> #!/opt/local/bin/perl -w
> use strict;
> use FileCache;
> my $a01;
> $a01 = 'a01file';
> cacheout $a01;
> print $a01 "XYZ\n";
> 
> 



how to ??

2001-05-01 Thread Daniel Choong



okie, this probably sounds very simple but i dunno how
to do it. i just learnt perl. i need some tips on how
to use a perl script to automate the updating of files
on multiple servers. i am trying to use ftp but i do
not know how to write the script to read the output
from ftp, then send the username and passwd, then
detect the prompt and send the commands. i suppose
there's a simple way to do that but i am lost.
anyone knows how to do that? i tried using IPC::Open2
but i dunno how to use it properly.
daniel



__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



Running jobs in the background with backticks

2001-05-24 Thread Cron, Daniel


It seems that when I use backticks to kick off a job in the background, my
perl script waits until the background job finishes.
But it seems that the system command actually kicks things off and moves on.

Here a perl script which demonstrates this behavior:

#!/opt/local/bin/perl -w
use strict;
print "About to execute system\n";
system ("sleep 10 &");
print "Done with system\n";
print "About to execute backticks\n";
`sleep 10 &`;
print "Done with backticks\n";

I really don't understand this behavior.
Can someone explain why this is happening?





Regex problem

2001-05-28 Thread Bornaz, Daniel

Dear all,

I am trying the following code using ActivePerl 5.6.1.626, in my quest to
find the minimal string between "bar" and "river":

$stt="The food is under the bar in the barn in the river.";
$stt=~/bar(.*?)river/;
print "$&";

The output is:
bar in the barn in the river

Instead of the expected: 
barn in the river

guaranteed by the question mark that follows the star. In fact, the question
mark does not affect the output at all.
It seems to me that the greediness of the search expresion is only valid if
the string that you want to match shrinks from left to right, like looking
for the minimal match between "food" and "in", like in the following code:

$stt="The food is under the bar in the barn in the river.";
$stt=~/food(.*?)in/;
print "$&";

Which prints correctly:
food is under the bar in


Can anyone explain this, please?

Best regards,

Daniel Bornaz
GBS Specialist
~~
 Compaq Computer Romania
   77 Emanoil Porumbaru St.
   Bucharest Romania
   Tel.: +401 222 23 24
   Fax : +401 223 40 10
~~~




Tk Question

2001-05-29 Thread Bornaz, Daniel


Can anyone help me by telling me how can I scroll in program to the end of a
Scrolled object after adding some text that goes out of the displayed area?


Many thanks in advance,

Daniel Bornaz
GBS Specialist
~~
 Compaq Computer Romania
   77 Emanoil Porumbaru St.
   Bucharest Romania
   Tel.: +401 222 23 24
   Fax : +401 223 40 10
~~~




RE: Hashes and loops

2001-09-19 Thread Daniel Falkenberg

> List,
> 
> I have the following while loop that goes and pings a whole heap of
servers around our company.  If one is broken or doesn't respond to the
ping my code e-mails me the results of which server isn't responding.
This all works well but I really need it to be able to keep pinging all
the servers and if one breaks I need the hostname of that to be stored
in hash.  Ie a new hash.  
> 
> First hash (Ping all these servers)
> 
> %first_hash (
> 
> 1server.com' => 'Server1',
> 2server.com' => 'Server2',
> 3server.com' => 'Server3',
> 4server.com' => 'Server4'
> 
> }
> 
> The script pings all the above servers.  Then if one doesn't respond
and nothing is returned.  Then I create another hash...
> 
> %second_hash; #server that didn't resond to ping request. 
> 
> This is all easy but I need my script to continue pinging the other
servers every 4 minutes.  And also keep checking the servers in the
second hash for con ectivity and if they are conected I need the key
from the second hash placed back into the first hash because it is live
again.
> 
> I just need a quick tutorial on how I would go about this ?
> 
> Hope this makes sense :)
> 
> Regards,
> 
> Dan
> 
> 
> while (1) {
>  $sleep   = 5; #Sleep time in seconds. Have this at around 5 minutes
or 300 seconds
>  $server  = 'mail.server.com';  #Mail server.  Change to suit other
environments
>  $p   = Net::Ping->new("icmp", 1, 2);  #Ping object.  Uses icmp
protocal
>  foreach $host (sort keys (%host)) {
>  unless ($p->ping($host)) {
>print "$host hello \n";
> $name = $host{$host}; #Name of the machine/host
> %mail   = ( To  => '[EMAIL PROTECTED]',
> From=> '[EMAIL PROTECTED]',
> Subject => $subject,
> Message => $message,
> SMTP=> $server,
> );
> sendmail(%mail) or die $Mail::Sendmail::error;
> delete $host{$host};
> }
> }
> sleep $sleep;
> }

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




Continuing a while loop

2001-09-20 Thread Daniel Falkenberg

List,

I need the code below to execute the sub double_check($host) but I still
want the while loop to continue exactly what it's doing.

Is this possible with Perl|? 

while (1) {
 $p   = Net::Ping->new("icmp", 4, 2);  #Ping object.  Uses icmp
protocal
 foreach $host (sort keys (%host)) {
 unless ($p->ping($host)) {
$name = $host{$host}; #Name of the machine/host
delete $host{$host};
double_check($host);
}
  }
}

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Running a Perl Script from a Perl script

2001-09-24 Thread Daniel Falkenberg

List,

This may seem like an odd questiong but to avoid race conditions I need
to be able to run a Perl script from a Perl script (Ie execute it
without any user interaction).  Is this possbile.

if (something = something) {
RUN NEW PERL SCRIPT HERE THEN CONTINUE WITH THE PERL SCRIPT
ALREADY RUNNING
} else {
print "Everything is fine \n";
}

Regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Perl daemon and fork problems

2001-09-24 Thread Daniel Falkenberg

List,

I have read and understood as much as I can about fork.  But I have the
following problem where I need to start up a second script in my first
script.  Problem is, if I have one already started as a deamon the
second won't start as a deamon.  Am I doing something terribly wrong
here?


This is the first script... script1

deamonize();

sub daemonize {
chdir '/var/daemon2'   or die "Can't chdir to /var/daemon: $!";
open STDIN, '/dev/null'or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork)or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask;
}

While(1) {
if (this == that) {
exec("perl_script2.pl"); #??? And continue the while
loop as a daemon <
} else {
#Continue
}
}

This is the second script... script2

deamonize();

sub daemonize {
chdir '/var/daemon2'   or die "Can't chdir to /var/daemon: $!";
open STDIN, '/dev/null'or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork)or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask;
}

While(1) {
if (this == that) {
print "hello world! \n";
} else {
#Continue
}
}




==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




RE: :FTP module

2001-09-25 Thread Daniel Falkenberg

Sofia,

Try... http://search.cpan.org

HIH,

Daniel Falkenberg

>From where can I download the Net::FTP module?

Thanks in advance

__
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo!
Messenger. http://im.yahoo.com

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




Interesting TOP results

2001-09-26 Thread Daniel Falkenberg

Hi all,

I have just created a perl script that daemonizes itself and runs as a
process in the background (Hence daemon :) ).  I just ran a TOP on my
server and noticed that the perl script uses 8.8% memory.  and about 1%
CPU.  Now the script continually runs through a while loop.  Before I
try it would it be a good idea to have this while loop sleep for about
20 seconds (sleep 20;) and then have it run again.  Would this place
less strain on the server?

Daemonize();

while (1) {
 
#Do stuff and put lots of strain on my server 

}

OR

while (1)  {

#Do stuff but after this make the while loop sleep for 20
seconds
sleep 20;
}

Would this make any difference. Or has any one done any thing like this
b4?

Kind regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Unix time

2001-09-26 Thread Daniel Falkenberg

Hi all,

Can some one please tell me how I would go about printing Unix time with
Perl.

I figured it would go something like this...

$unixtime = localtime();

print $unixtime;

Cheers,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Re: date/time

2001-10-01 Thread Daniel Gardner

YR> Looking for a little help for taking current time (from time) and finding
YR> the time until 1 minute after midnight.

YR> I have a daemon process (perl script) that needs to die ever new day,
YR> the process should only run from 12:01 AM Today -  l 12:01 AM Tomorrow


as ever there's more than one way to do it...

there's a variable called $^T (or $BASETIME) if you use Engligh, which
is the number of seconds since the epoch when your script started, the
time() function tells you what the number of seconds past the epoch is
now.

probably the easiest thing for you to do is a simple test like:

if (time > ($^T + (60*60*24))) {
# we want to finish
}

but you could do something clever with POSIX::strftime as well...

it depends on how exact you need to be...

hth,
daniel


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




Modifying a text file with perl.

2001-10-01 Thread Daniel Falkenberg

List,

I have comma seperated text file here with 3 entries per line...

hello, world, 1

Is it possible with perl to change that value of 1 to 0?

Regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Piping ifconfig to a text file

2001-10-03 Thread Daniel Falkenberg

List,

Can some one help me with opening ifconfig and pipe it to a text file.
Then I want to be able to view that file.

How would I go about this?

open IFCONFIG, "/sbin/ifconfig";
 $file=;
 print $file;



Kind regards,

Daniel Falkenberg

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Piping ifconfig to a text file

2001-10-03 Thread Daniel Falkenberg

> List,
> 
> Can some one help me with opening ifconfig and pipe it to a text file.
> Then I want to be able to view that file.
> 
> How would I go about this?
> 
> open IFCONFIG, "/sbin/ifconfig";
>  $file=;
>  print $file;
> 
> 
> 
> Kind regards,
> 
> Daniel Falkenberg
> 
> ==
> VINTEK CONSULTING PTY LTD
> (ACN 088 825 209)
> Email:  [EMAIL PROTECTED]
> WWW:http://www.vintek.net
> Tel:(08) 8523 5035
> Fax:(08) 8523 2104
> Snail:  P.O. Box 312
> Gawler   SA   5118
> ==
> 

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




Don't print...

2001-10-03 Thread Daniel Falkenberg

List,

Can some one tell me why it is that the following code prints the
results on the screen when I don't have the print command in there at
all???

$shell = ifconfig("ppp0");
cp($shell, "/etc/ppp/ppp");

Regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Copy file output to a text file

2001-10-03 Thread Daniel Falkenberg

> List,
> 
> I have this problem that has been bothering me all day.  All I want is
> to be able to copy the out put of ifconfig to a text file
> /etc/ppp/ppp.txt
> 
> I have tried so many things but I can't get it to work.  Once I have
> done this I need to be able to extract the ADSL ip address from ppp0
> and then store that in a variable.
> 
> Is this possible or am I wasting my time?
> 
> Dan
> 
> ==
> VINTEK CONSULTING PTY LTD
> (ACN 088 825 209)
> Email:  [EMAIL PROTECTED]
> WWW:http://www.vintek.net
> Tel:(08) 8523 5035
> Fax:(08) 8523 2104
> Snail:  P.O. Box 312
> Gawler   SA   5118
> ==
> 

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




Help with regular expression.

2001-10-04 Thread Daniel Falkenberg

List,

I have an IP address within this regular expression that I need
extracting and stored in a variable.  Could some one offer some help on
this?  The line is as follows...

  inet addr:144.137.215.25  P-t-P:172.31.28.24
Mask:255.255.255.255

I need to extract the inet addr: i.e 144.137.215.25 and store it in a
variable.

I am very new to regexes.  So any help would be greatly appriciated.

Daniel Falkenberg. 

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Config file problems

2001-10-04 Thread Daniel Falkenberg

List,

I have a problem where I need a while loop to go through a config file
change the remote IP address every time it finds it.  There is blank
line after each cfg part.  I also need it to check to make sure that the
data always starts with...

Tunnel Name,
IP tunnel
Remote IP

I suppose I would do some thing like the following

sub read_config() {
open CFGFILE, "<$cfg";
while ($line=) {
chomp $line;
@line=split(/=/, $line);
$config{$line[0]}=$line[1];

#If the blocks do not follow rules like Tunnel Name then
die with error <--- but how would I go aboout doing this?

}
close CFGFILE;
}

 

Config file

Tunnel Name, Test1
IP tunnel,192.168.0.1
Remote IP,150.101.1.1

Tunnel Name, Test2
IP tunnel,192.168.0.6
Remote IP,150.101.1.6

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Cookie worries...

2001-10-21 Thread Daniel Falkenberg

Hi all.

Could some one have a look at the following code and tell me my the 3rd
script can't read the cookie and allow me to access the page?  Basically
I am sure I am not doing anything wrong.  I can see the cookie set in my
browser through the users windows explorer.  It looks the same as
this...

test
test
'path'
0
1157283456
29448914
789082896
29448899

Is there a problem with the third script?  It doesn't seem to be
populating $user?

Any suggestions or comments would be creatly appriciated.

Kind regards,

Daniel Falkenberg

FIRST SCRIPT.cgi - LOGIN PAGE

#Normal stuff here #!/usr/bin...

my $username = "test";
my $password = "test";
my $user = param('username');
my $pass = param('password');

logout()  if($action eq "logout");
login_page()  unless($pass);

my $valid = Check_Login($user, $pass);
if($valid) {
  my $cookie = Create_Cookie("+30m", $user);
  print redirect(-uri=>"safilm", -cookie=>$cookie);
  exit;
}
else{
  my $time = time();
  print redirect(-uri=>"login?$time");
  exit;
}

sub logout{
   my $time = time();
   my $cookie = Create_Cookie("-30m", "");
   print redirect(-uri=>"login?$time", -cookie=>$cookie);
   exit;
}

sub Create_Cookie{
  my $exp = shift;
  my $val = shift;
  my $cookie = cookie ( -name=> 'test',
-value   => $val,
-expires => $exp,
-path=> ''
);
  return($cookie);
}

sub Check_Login{
my $user = shift;
my $pass = shift;
($password eq $pass) ? return 1 : return 0;
}

sub login {
print header();
print<"login");
exit;
  }
}

1;

SCRIPT 3.cgi - MAIN PAGE

#Normal stuff here #!/usr/bin...

my $user  = Check_Cookie();
my $action= param('action');

print header();
print<http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Net::Ping

2001-10-22 Thread Daniel Falkenberg

Hi all,

I have just been playing with Net::Ping recently and have a few
questions that I need clarifing if any one has the time.

Firstly.  I have a host using a 56k modem connection.  When I ping these
servers using the ping object

$p   = Net::Ping->new("icmp");

If the server that is being pinged doesn't respond it generates an error
message.  Then when I go and ping the supposedly failed server manually
from a command prompt it responds.

Does any one have any ideas as to why this is doing that?

I have tried changing the time out to the maximum but this doesn't seem
to work.  With Net::Ping can I issue something that says...

OK ping this server 5 times and if the server resonds 1 or more times
out of the 5 then don't generate the error message.  At the moment I
think with net ping it only pings a machine once.  If it doesn't respond
then it sends and error message.

Any ideas would be greatly appriciated.

Kind regards,

Daniel Falkenberg


==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




How weird is this...

2001-10-23 Thread Daniel Falkenberg

Hi all,

ATM I am playing with cookies.  I just came accross a really weird
problem I am having...

I would set the cookie in my browser and have in expire in 10 minutes.
Then I logged out of my webpage and have the cookie deleted.  This
worked fine.  I  then logged back into my webpage and noticed that the
cookie was still set in the browser, but, when I went and logged out it
didn't and all it did was delete the data I had placed in the cookie.
It's no big deal because the user can't access the page again.

Weird!

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




System calls through a CGI script

2001-10-23 Thread Daniel Falkenberg

Hi all,

I am working on a CGI script that needs to execute this command from a
sub within the script...

system("/usr/sbin/adduser test");

I can issue this from a single non-CGI script and it works fine.  I have
also double checked the permission on the file but it still won't
execute this system call?

Does any one have any sugestions here?

Kind Regards,

Daniel Falkenberg 

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Regex frustration...

2001-10-24 Thread Daniel Falkenberg

Hi all,

I am working on a regex that just won't do what it's told...

Basically I have a file like the following...

test1:x:26:testing1 
test2:x:45:testing2
test3:x:45:testing3
test4:x:23:testing4
test5:x:45:testing5

Now I need to strip everything in there that is before the first ':' and
only match anything with the ':45'.  I also need to be able to extract
everything past the last ':' and then store her in a hash like this...

%crud = {
'test2' => 'testing2',
'test3' => 'testing3',   #Because these have 45 within them
:)
'test5' => 'testing5'
}'

Here is what I have so far...

$name_of_hash = "Crud";

open FILE 
while () {
$keys_of_hash = $1 if /^\s*(.*?)\s*:/;
}
close FILE;

This is fine because it now finds the first part ie...

test1
test2
test3
test4
test5

Can some one give me some suggestions on where I would go next?

Regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Chainging values in a hash..

2001-10-25 Thread Daniel Falkenberg

Hey List,

I am working on a problem where I have a hash of a hash that need
updating and to be writen back into a text file.  At the moment the hash
looks like this...

%hash = (
 'Crud1' => {
  'test1' => 'crud10',
  'test2' => 'crud11'
},
 'Crud2' => {
   'test1' => 'crud10',
   'test2' => 'crud11'

 },
 'Crud3' => {
'test1' => 'crud10',
'test2' => 'crud11'
  }
   );

Is it possible to change all the values of crud10 to crud9.  At the
moment my code looks like this...

read_config(); #create hash like above. At the moment it works fine
#change variable of crud10 to crud 9...
$hash{$hashname}{'test1'}= "crud9";
write_config($tunnelfile, %tunnels);
#Write config looks like this...

sub write_config {
open FILE, ">$tunnelfile" or die "cannot open $tunnelfile: $!\n";
for $t (keys %hash) {
print $t, "\t\n\n";;
print FILE "[$t]\n";
print FILE "$_=$hash{$t}{$_}\n" for keys %{$tunnels{$t}};
}
close(FILE)   or die "Closing: $!";
}

But for some reason write_config will only change %Crud3 ( 'test1' =>
'crud9'); ...

and nothing else.  Am I missing something major here?

Kind regards,

Dan
 
==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Stupid question...

2001-10-26 Thread Daniel Falkenberg

Hey List,

This may sound like the stupidest question so far but, I was wondering
the other day is it possible for perl programs (script.pl) to be
compiled like a C/C++ programs are?  I can't really find any
documentation on this so I thought I figured I would ask some one here.

Regards,

Daniel Falkenberg

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




Changing a Unix password.

2001-10-28 Thread Daniel Falkenberg

Hi all,

I have a small CGI script here that is used to change users Unix
passwords.  Now before we go into security let me just tell you that the
script is only accessable via a user name and password.  The script is
also only accessable on an internal network and the every character in
each parameter is checked.

Now that I have mentioned that I was hoping for some input in how I
would go about this.  I suppose I could do something like this...

$password   = param('new_passoword'); #Taint check
$confirm_pasword  = param('confirm_password');  #Taint check

#I was now thinking of doing some system calls here. I.e...

if ($password ne $confirm_password) {
print "Sorry passwords do not match";
} else {
system("passwd $username $password");
system("$password");
system("$password");
print "Password changed!\n";
}

but... as the code shows those system commands will not work because it
looks look after each system command it ends.  Therefore my question
is...

How can I insert the New Unix Password through a CGI script?

Regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Updating /etc/passwd

2001-10-29 Thread Daniel Falkenberg

Hi all,

I really need some help on updateing the Unix /etc/passwd file.

Basically I have a script that reads it like the following...

$file = '/etc/passwd';

my $hash_ref;
my %hash_ref;
open FILE, "$file" or die "$file: $!\n";
while (  ) {
my @list = split ':';
if($list[3] == 45) {
  $hash_ref{$list[4]}=$list[0];
}
#return %hash_ref;
}
close FILE;

which creates the hash...

%hash_ref (
'Comment' => 'username',
'Comment1' => 'username1',
'Comment2' => 'username2'
 );

Now I have no problem updating the hash.  For example I could quite
easily add a * in front of a username like so...

$hash_ref{'Comment'}= "*username";

Then hash_ref woyuld now read the following...

%hash_ref (
'Comment' => '*username',
'Comment1' => 'username1',
'Comment2' => 'username2'
 );

But the problem I am having is how would I go about telling my perl
script to go and place replace the username of username to *username.

Any ideas/suggestions would be greatly appriciated.

Regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




sub read_config is killing my daemon

2001-10-29 Thread Daniel Falkenberg

Hey All,

I have a perl script here (below) that becomes a daemon when ever I run
it.  But when ever it goes to read the script it it dies on me?

Can any one tell me what is going on here?

If I remark (#) the read_config(); in the while loop the daemon doesn't
break.  Does any one here have any suggestions?

Regards,

Dan

#!/usr/bin/perl -w

use POSIX qw(setsid);
use Data::Dumper;
use Net::SSH::Perl;

chdir '/' or die "Can't chdir to /: $!";
umask 0;
open STDIN, '/dev/null'   or die "Can't read /dev/null: $!";
#open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork)   or die "Can't fork: $!";
exit if $pid;
setsidor die "Can't start a new session: $!";

my $tunnelfile = 'config';  #Sets the config file as $tunnelfile.
my $sleep  = 2;#How long do you want the script to check for
IP change?
my $srt= 0;
my %tunnels;

while(1) {
   sleep(1);
   print "Hello...\n";
   system ("ifconfig ppp0 > /etc/ppp/ppp.txt");
   open (FH, "; #Store ppp0 as an array
   $test[1] =~ /addr:(\d+\.\d+.\d+\.\d+)/; #Extact the IP address here
and stote as $1
   close(FH);
   read_config();
}

sub read_config {
open (FILE, "<$tunnelfile") or die "cannot open '$tunnelfile':
$!\n";
while(  ) {
   my $tunnelname = $1 and next if /^\s*\[\s*(.*?)\s*\]\s*$/;
   next unless defined $tunnelname && /^\s*(.*?)\s*=\s*(.*?)\s*$/;
   $tunnels{$tunnelname}{$1} = $2;
}
close(FILE);
return %tunnels;
}

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Changing users postfix password

2001-10-30 Thread Daniel Falkenberg

Hey all,

I am working on a CGI script where I need it to change a users postfix
password.  At the moment my script runs as apache and I really need to
issue this command...

system("echo $password | /usr/bin/sudo passwd --stdin $username");

This command works from a Unix prompt but doesn't work from the CGI
script.  Now for testing purposes only both apache and myself have full
control to be able to issue this commnand.  The problem is it won't
change.  Any one have any ideas on how I could do this or any other ways
I could accomplish this?

Regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Re: create hash slice from hash

2001-10-31 Thread Daniel Gardner

LN> I am attempting to create a hash slice from a hash.  The hash is:

LN> %hash =("test1" => "test10",
LN>"test2" => "test12" ,
LN>   "test3" => "test13")

LN> I want the slice to include only the keys test1 and test3.  How can I
LN> accomplish this?

you could use map:

  my %new_hash = map { $_ => $hash{$_} } qw(test1 test2);

map is a really useful function...

hth,
daniel


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




Re: Regex syntax

2001-10-31 Thread Daniel Gardner

FN> Hey,

FN> On an Oct 25 thread, someone asked how to remove trailing spaces.
FN> The response was $Value =~ s/\s+$//.

FN> Question.

FN> 1. The string upon which this operation was made is on $_ correct?

no - $Value.

  $Value = 'foo';
  $Value =~ s/\s+$//;
  $Value eq 'foo';


FN> 2. If I've made the assignment $tempstring = substr($_ ,0,20) how do I
FN> remove trailing spaces from $tempstring?

so do $tempstring =~ s/\s+//;


hth,
daniel


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




Re: array of hashes

2001-10-31 Thread Daniel Gardner

S> I have a systems hash that contains the type of system
S> as keys and the name of the machines as values:

S> %systems = (
S>sgi   => ["sgi1", "sgi2"],
S>linux => ["linux1", "linux2"],
S>dec   => ["dec1", "dec2"]
S> };

S> Now, each type of system has default values like an
S> email help address, shell used, users home directory,
S> etc.  Something like this:

S> %default = (
S> sgi   => ["sgi-help","/bin/csh","/home"],
S> linux =>
S> ["someaddress-help","/bin/bash","/usr/home"],
S> dec   => ["help-desk","bin/kcsh","/usr1/home"]
S> );

S> Is there a way to combine this last hash into the
S> first one or should I keep them separate?

there's loads of ways you could hold the data. the first one that
comes to mind looks like:

 %systems = (
sgi   =>  { defaults => ["sgi-help","/bin/csh","/home"],
machines => ["sgi1", "sgi2"],
  },
linux =>  { defaults => ["someaddress-help","/bin/bash","/usr/home"],
machines => ["linux1", "linux2"],
  },
dec   =>  { defaults => ["help-desk","bin/kcsh","/usr1/home"],
    machines => ["dec1", "dec2"],
  },
 );

but it really depends on what it is you're doing with the data. you
want to design your data structure around the processing, rather than
designing a data structure that looks nice, but makes the code hard.

perhaps if you let us know what you want to do with it we might be
able to give some suggestions.

hth,
daniel


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




Encryption

2001-10-31 Thread Daniel Falkenberg

Hey all,

Just wondering what the best way to find out what encryption I am
running on my Unix maxchine. Basically I have a problem where I need to
add a user from a Perl script something similar to the following...

use Crypt::PasswdMD5;

my $salt;
$password = "password";
$cryptedpassword = unix_md5_crypt($password, $salt);
system("/usr/sbin/adduser  -g 45 -p $cryptedpassword -c
'' -s /bin/false");

This way (hopefully) I don't have to change the password manually with
passwd.  But the problem I am facing is... when I went to test the
accout it still didn't accept the password.  So I changed the password
using passwd and that worked fine.  

Any one have any ideas how I could either find out what encryption I am
using or how I would go about this?

Regards,

Dan 


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




Silly problem

2001-11-02 Thread Daniel Falkenberg

G'day All,

I have this very very simple problem that I can't figure out.  Basically
I have a 1 line text file with an IP address in it like so...

192.168.0.2

Now all I want to do is open this file up and extract the IP address
from it.  Now the good thing is I can do this OK but whenever I extract
it it seems to be appending a new line on the end of it.  Can some one
help me and give me some ideas on what I am doing wrong?  My code so far
looks like this...

open (FH, "<$file"); #...and open the textfile for reading
@line=; #Store ppp0 as an array
$line =~ /^(\d+\.\d+.\d+\.\d+)/; #Extact the IP address here and stote
as $1
print @test;
close(FH);

printing @test works fine but it appends a new line.  The code also
won't assign $1 to the IP address?

Is it something simple I am doing wrong?

Regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Can any one see any thing wrong with this?

2001-11-08 Thread Daniel Falkenberg

Hey all,

Now basically whenever I try and connect it seems to login ok but when
ever try and issue the command I get the following error

Permission denied at ./test.pl line 12

$remote_host = "xxx.xxx.xxx.xxx";
$user= "user";
$pass= "password";

my $ssh  = Net::SSH::Perl->new($remote_host);
print "Now logging into MaxBev\n";
$ssh->login($user, $pass);
$ssh->cmd("echo test > /home/tunnel/test"); <-- Line 12
print "Done done and done!\n";

Now I can log in OK manually and issue the same command.  Would I want
to start checking permissions?

Ohh and yes the account has been setup on the remote host.

Regards,

Dan

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




[OT] NT mailing list

2001-11-08 Thread Daniel Falkenberg

Hi all,

I am really sorry to bother all of you with this one.  But I am about to
start working on a new project using Active Perl but before I begin I
need to know some information on Win2k/NT4.  My question is does any one
know of any windows Mailing lists?  Now I have searched the net for
these mailing lists but I can't seem to find any.

Thx,
Dan

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




/etc/passwd problem

2001-11-08 Thread Daniel Falkenberg

Hey all,

I have a script here that I want to be able to add a * next to all the
users in that I want with the UID of 45 in /etc/passwd.

Example...

test:x:530:45:Test Name:/home/test:/bin/false
test2:x:531:45:Test Name2:/home/test2:/bin/false

I want...

*test:x:530:45:Test Name:/home/test:/bin/false  <--- With the *
test2:x:531:45:Test Name2:/home/test2:/bin/false

All I want to be able to do is use STDIN for the user to input the
username they want to add a star next to and then do it but only for
users with a UID of 45.

Any ideas ont this one?

Regards,

Dan


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




Re: Off-Topic (200%) - Where are you from?

2001-11-10 Thread Daniel Gardner

Manchester, UK


Friday, November 09, 2001, 4:07:57 PM, you wrote:

JE> Leeds, UK

JE> -Original Message-
JE> From: Mike Gargiullo [mailto:[EMAIL PROTECTED]]
JE> Sent: 09 November 2001 16:13
JE> To: [EMAIL PROTECTED]
JE> Subject: RE: Off-Topic (200%) - Where are you from?


JE> Princeton Jct., New Jersey

JE> -Original Message-
JE> From: dan radom [mailto:[EMAIL PROTECTED]]
JE> Sent: Friday, November 09, 2001 11:08 AM
JE> To: [EMAIL PROTECTED]
JE> Subject: Re: Off-Topic (200%) - Where are you from?


JE> boulder, colorado

JE> * Etienne Marcotte ([EMAIL PROTECTED]) wrote:
>> By reading the messages everyday I can guess most of us are from
JE> United
>> States right? And since there are not a lot of messages in (my)
JE> morning
>> time, probably means most are from the west coast (different
JE> timezone).
>> 
>> Am I right?
>> 
>> I'm from Quebec, Canada.. and you?
>> 
>> Sorry if it's way off topic, I hope the ones that hate OT subject
>> filtered *off*topic* in their  emails!
>> 
>> Etienne
>> 
>> -- 
>> 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]




What is happening here...?

2001-11-12 Thread Daniel Falkenberg

Hi all,

Below is a chunk of code that I don't really know what's going on?
Could some one give me a few ideas?

perl -F: -i -ape'$F[3] == 45 && s/^/*/' /etc/passwd

Regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Can I issue this from an actual script?

2001-11-12 Thread Daniel Falkenberg

Hi all,

Can this code below be issued from an actual perl script?

perl -F: -i -ape'$F[3] == 45 && $_ =~ /^test/ && s/^/*/' /etc/passwd

regards,

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




RE: What is happening here...?

2001-11-12 Thread Daniel Falkenberg

Curtis,

Cheers for that that makes alot more sense now :).  Yes your are correct
about the /etc/passwd file.  It's all well and good to be able to issue
that command from a command line, but what if I wanted to issue the
exact same code but from a script?

Regards,

Dan

Dan,

Here's a list of the command line switches used and their meaning:

-F(regex) A regular expression to split on if -a is used.
-aTurns on autosplit mode with -n or -p. Splits to @F
-pAssumes an input loop around the script (while(<>){...})
-iInplace edit if <> is used. (-p)
-eAllows you to execute a single line of script

So... not being a Unix/Linux geek, I'm not sure about the structure of
/etc/passwd, but it appears
that fields in this file are delimited by a colon (which -F will split
on) and if the 4th field
($F[3]) is equal to 45, an asterisk will be placed at the beginning of
the line (s/^/*/).

Someone please follow-up if I got any of this wrong.

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

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




expanding a pattern

2001-11-13 Thread Daniel Kidger


I have a pattern like
   $hosts = "fred[1,3-7,9-22]"

Is there a simple way to generate an expanded list like:
   fred1 fred3 fred4 fred5 ... 
etc.
?



Daniel.

--
Dr. Dan Kidger, Quadrics Ltd.  [EMAIL PROTECTED]
One Bridewell St., Bristol, BS1 2AA, UK 0117 915 5505
--- www.quadrics.com 


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




accepting --stdin from sudo command

2001-11-13 Thread Daniel Falkenberg

Hey all,

I really want to be able to issue this command from a perl script but
unfortunatly I don't want to have to use the expect programming language
to input the password.  I have the following command below... Does this
look OK?

echo password | sudo cp -f /etc/passwd /home/me --stdin

Cheers,

Dan

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




Complex question about GD::Graph

2001-11-13 Thread Daniel Falkenberg

Hey all,

I have some user details that I want placed in this graph.  Probem is my
Perl skills arn't all that good.  Could some one give me some ideas with
the following?

I have a hash here (%users) the Key here is their static IP address.
The value is just some data.  Now the problem I am having is that in my
@data below I need the Key to be placed on the X axis and the data to be
placed on the Y axis.  

%users = (
   '192.168.30.15' => '0.0365829467773438',
   '192.168.30.232' => '0.927815437316895',
   '192.168.30.32' => '0.159876823425293'
 );



my @data = (
  [ "192.168.30.15", "192.168.30.232", "192.168.30.32"],
  [ $valueofhash1,  $valueofhash2,  $valueofhash3,],
);

Now the rest is pretty straight foward.  I could manually placed these
in but if someone else is added to the hash then I don't really want to
have to be adding it manually each time to @data.  Could some one give
me some ideas on what I would do here?

something like...

my @data = (
  [ $_[key1$_], $_[key2$_], $_[key3$_]],
  [ $valueofhash1$_,  $valueofhash2$_,  $valueofhash3$_,],
);


#  my $my_graph = new GD::Graph::bars();

#  $my_graph->set(
#x_label => 'User',
#y_label => 'Data(MB)',
#title => 'Safilm Internet Usage',
#y_max_value => 60,
#y_tick_number => 60,
#y_label_skip => 2,
#
## shadows
#bar_spacing => 12,
#shadow_depth => 8,
#shadowclr => 'dwhite',
#)
#or warn $my_graph->error;

#open PNG, ">usage.png";
#move("usage.png", "./data.jpg")
#or die "move failed: $!";
#print PNG $my_graph->plot(\@data)->png;
#close PNG;

#my $map = new GD::Graph::Map($my_graph);
#($map->imagemap("./data.png", \@data));

regards,

Dan

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




IP accounting

2001-11-15 Thread Daniel Falkenberg

Hey all,

I am just about to start a new project.  Before I start I wouldn't mind
some input if any one has any

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




IP accounting

2001-11-15 Thread Daniel Falkenberg

Hello List,

Just about to begin a new project where I am going to start to create
some IP accounting software using Perl or coarse.  Before I being I
woudn't mind getting some information from any one that has done any of
this before.  Firstly the network I will be monitoring will consist of
users using DHCP on WinNT/98/95/2000 machies.  Any ideas on where I
would start with this?

Regards,

Dan

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




Adding a line to the end of /etc/shadow

2001-11-15 Thread Daniel Falkenberg

Hey all,

Just a quick question I want to be able to a line from /etc/passwd and
append it to the end of /etc/shadow.  So far I have the following.

#!/usr/bin/perl -w

my $passwdFILE = '/etc/passed'; #System password file
my #shadowFILE = '/etc/shadow';
my $user = 'test'; #User details to be moved accross from /etc/passwd to
/etc/shadow

open FILE, "$passwdFILE"  or die "Cannot open $passwdFILE in for reading
ONLY:$!";
my @lines = ;
if ( $line->[3] == 45 && $array_ref->[0] =~ /^$user/ ) {
#open /etc/shadow for appending..
open SHADOW, ">>$shadowFILE"  or die "Cannot open $passwdFILE in
for reading ONLY:$!";
#what to go here?
}

Any help here would be greatly appriciated.

Dan

==
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:http://www.vintek.net
Tel:(08) 8523 5035
Fax:(08) 8523 2104
Snail:  P.O. Box 312
Gawler   SA   5118
==


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




Appening a line to /etc/passwd

2001-11-15 Thread Daniel Falkenberg

Hey List,

Just a quick question.  I have the following code below...

sub ADD_SHADOW {
  my $passwdFILE  = '/etc/passwd';
  my $shadow  = '/etc/shadow';

  open FILE,   "$passwdFILE"  or die "Cannot open $passwdFILE in READ
ONLY mode:$!";
  open SHADOW, ">>$shadow"  or die "Cannot open $shadow in APPENDING
mode:$!";
  my @lines = ;
  @lines = map { add_star( $_ ) }
  map { [split /:/] } @lines;
  seek SHADOW, 0, 0;
  print SHADOW @lines;
  truncate( SHADOW, tell(SHADOW) );
  close FILE;
  close SHADOW;

  sub add_star {
my $array_ref = shift;
if ( $array_ref->[3] == 45 && $array_ref->[0] =~ /^$new_user/ ) {
  print $array_ref;
   }
   return join ':', @$array_ref;
   }
}

Now what I want to do is only append $array_ref to /etc/shadow I do not
want to append all of /etc/passwd to /etc/shadow.  My problem is that I
am doing just that and I can't just append the elemnt of the array
($array_ref) to /etc/passwd

Is there a simplefix to this one?

Regards,

Dan

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




Re: pattern matching

2001-11-18 Thread Daniel Gardner

PT> Hi,
PT> Iam a beginner in perl.I have one question,
PT> Iam trying to write one prog,in which i have to search for one word in a
PT> file,
PT> If I found that word,print next 4 lines.
PT> PLs help me,how to write code.
PT> cheers,
PT> prasa.


something like this should do the trick:

open FILE, ") {
   # if the line we just read contains your word
   # then read the next four lines and print them
   if (/your_word/) {
   # loop four times (four lines)
   for (1..4) {
   # specify scalar here to ensure correct context
   print scalar ;
   } # end for
   } # end if
} # end while
close FILE;


if you want to stop after you've found the word the first time, then
add "last;" below "} # end for"

we need to say "scalar" because otherwise perl will think that we want
to print the whole of the file. "print" works in array context, and
the angle brackets <> will return all the lines in array context. if
we force it to scalar context it will only return the next line.

hth,
daniel


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




Re: include a file

2001-11-19 Thread Daniel Gardner

sre> sorry for this question, but i'm not a perl programmer. =\

sre> is there any similar function to php's "include()"?

sre> i want to include an html file into the output the user will get when
sre> opening the .pl


you could use a function something like:

sub echo_file {
  my ($filename) = @_;

  open my $fh, $filename;
  if (!$fh) {
print "Could not include $filename: $!";
return;
  }

  # slurp the whole file - don't try this with huge
  # files
  local $/ = undef;
  print <$fh>;
}


this doesn't work like the php include because it won't evaluate any
code that's in the other file, but if all you want to do is cat a file
containing html then this should be okay for you.


-- 
Best regards,
 Daniel


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




Re: [OT] Who's online, which is the best method?

2001-11-19 Thread Daniel Gardner

EM> What is the best method for a Who's online type of thing?

EM> Users can either log in or be automatically logged in with a cookie on
EM> the site.

EM> How can I "see" when the user is "there" or "gone"

EM> Am I better of reading a text file or a database table?
EM> With a cron to update every x minutes the number/handles of the users?

the way i'd probably do it would be to update a database table every
time a user logged in. the table could have (username, last_access)

there is no real way with HTTP to see id a user is "there" or "gone",
the only way you can tell is if a user has not accessed any pages for
x minutes... say if they haven't accessed for 10 minutes they are
"gone".

so, on all of your pages have a function to update the "last access"
table, and when you want to see who is "there", do a select from the
table where last_access > 10 minutes ago

if you have only a few users then this will be okay, but if you have
lots of users then a cron job to delete records where the user
hasn't accessed for more than 10 minutes running once a day or
something would be good.

hope that gives you some idea of a way to start...


-- 
Best regards,
 Daniel


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




Re: Use of packages

2001-11-19 Thread Daniel Gardner

Monday, November 19, 2001, 4:41:21 PM, Bruce Ferrell wrote:

BF> #begin example 2
BF> use packagename();
BF> sub1();
BF> sub2();
BF> #end example 2

BF> No can someone explain to me what, if anything is incorrect about the
BF> second example?  What I'm looking for is how sub-routines are used from
BF> a used module without the module name prefix.

you want to look at the Exporter module. there's full details here [1],
but what it basically comes down to is:

  package packagename;
  require Exporter;
  @ISA = qw(Exporter);

  @EXPORT_OK = qw(sub1 sub2);

  sub sub1 {
 perl code here
  }

  sub sub2 {
 perl code here
  }

  1;
  
and then in your script:

  use packagename qw(sub1 sub2);

  sub1();
  sub2();


[1] http://www.perldoc.com/perl5.6.1/lib/Exporter.html

-- 
Best regards,
 Daniel


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




Unix passwd rules

2001-11-19 Thread Daniel Falkenberg

Hi all,

I understand this is a little off topic, but it essetially this question
has alot to do with Perl. My question is what are the curent rules for a
Unix passwd? i.e How many characters?  Also has any one had anything to
do with the module Unix::PasswdFile.

I have the following code that inserts a current user into /etc/passwd.
For some unknown reason the users password is not inserted into
/etc/shadow.

my $pw = new Unix::PasswdFile "/etc/passwd";
$pw->user("$new_user", $pw->encpass("$new_pass"), $pw->maxuid + 1,
45,
"$new_fname $new_lname", "/home/$new_user", "/bin/false");
$pw->passwd("$new_user", $pw->encpass("$new_pass"));
$pw->commit();
undef $pw;

Any ideas?

Thx,

Dan

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




Daemons

2001-11-19 Thread Daniel Falkenberg

Hey all,

I am working with daemons at the moment.  What I want to know is...

1 - Is it possbile for my script to report a message everytime my
program dies.  My program currently runs as a daemon.  Sometimes I get
up in the morning and the program (Perl deamon) isn't running any more.

Thx,
Dan

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




Re[2]: Little pb with sort ...

2001-11-20 Thread Daniel Gardner

Tuesday, November 20, 2001, 6:27:44 PM, Brett W. McCoy wrote:

BWM> On Tue, 20 Nov 2001, Franck FASANO wrote:

>> Here is a little code :
>>
>> --
>> my @trav= ( 1, 12, 5, 3);
>> @trav=sort { $b cmp $a } @trav;
>>
>> foreach (@trav) {
>>  print " $_ ";
>> }
>> --
>>
>> After exec, we have :
>>  5  3  12  1

BWM> You're using the wrong operator.  You want { $b <=> $a} for your
BWM> comparison.

because <=> will do a numeric comparison, whereas cmp will do a string
comparison...

as strings "12" is less that "5", but as numbers 5 is obviously less
than 12.


-- 
Best regards,
 Daniel


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




Re[2]: Sorting a list of links by the linked text

2001-11-20 Thread Daniel Gardner

Tuesday, November 20, 2001, 7:11:34 PM, Wagner-David wrote:

WD> Here is a start:
WD> Script starts on next line:
WD> #!perl -w

WD> printf "%-20s - %-s\n", "SortField", "Url";
WD> foreach my $MyData (sort {$a->[2] cmp $b->[2]} map{ 
[$_,/="([^"]+).+\>([^<]+)\<\/a/i ] }  ) {
WD>printf "%-20s - %-s\n", $MyData->[2], $MyData->[1];
WD>  }

for those who won't have any clues whatsoever about that hunk of line
noise, i've expanded it out a bit and added some commentary.

  1: my @links;
  2: foreach my $line () {
  3:   my ($link, $desc) = $line =~ /="([^"]+).+\>([^<]+)\<\/a/i;
  4:   push @links, [ $link, $desc ];
  5: }
  6:
  7: my @sorted_links = sort { $a->[2] cmp $b->[2] } @links;
  8:
  9: foreach my $line (@sorted_links) {
 10:printf "%-20s - %-s\n", $line->[2], $line->[1];
 11: }
 
the overall aim is to read each line from the data file (what's under
__DATA__ [1]), find the interesting parts of each line, sort them, and
then print them.

using angle brackets around a file descriptor ("DATA" in this case)
will read a line in scalar context and the whole file in array
context. so our foreach line will read a line from the file, store it
in the "$line" variable and then execute the code within the loop.

that scary looking line 3 is, in fact, scary. it will pattern match on
$line, returning the right bits.

  /
   ="  # match an = then a " (like in href="
   ([^"]+) # then go find everything that's not a
   # quote and remember it
   .+  # find something, one or more time
   \>  # then a literal >
   ([^<]+) # everything that's not a < and remember it
   \<\/a   # then the string "[1] cmp $b->[1] } @links;

we need to sort the data, so we use the "sort" function [3]. this
function allows us to specify how we'd like the sorting to happen, and
in this case we want to sort on the anchor text. if you remember from
line 4 it's stored in the second element of our anonymous array.
because the first element is indexed at 0, the second is at position
1.

that'll give us all of the links sorted properly, so now we need to
print them out:

  9: foreach my $line (@sorted_links) {
 10:printf "%-20s - %-s\n", $line->[1], $line->[0];

printf is like doing a print and an sprintf [4]. that funny string
with the %'s in it is a template which says that we'd like the data
formatted please and how we'd like it formatted. in this case, we'd
like the first field left-justified within 20 spaces and the second
field just left-justified. [4] has good info about it.


hope that helps someone!


-- 
Best regards,
 Daniel


[1] http://www.perldoc.com/perl5.6.1/lib/SelfLoader.html#The-__DATA__-token
[2] http://www.perldoc.com/perl5.6.1/pod/perlreftut.html
[3] http://www.perldoc.com/perl5.6.1/pod/func/sort.html
[4] http://www.perldoc.com/perl5.6.1/pod/func/sprintf.html
[5] http://www.perldoc.com/perl5.6.1/pod/perlretut.html


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




Re: How to delete hash element

2001-11-20 Thread Daniel Gardner

Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa Ibrahim Ahmed wrote:

AMIA> If I know the key and offset of the element, how can I delete that hash
AMIA> element, please?

you can delete a hash element like:

  delete $hash{ the_key };

but i'm not sure what you mean by "the offset of the element"


-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


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





Re[2]: How to delete hash element

2001-11-20 Thread Daniel Gardner

Tuesday, November 20, 2001, 8:54:26 PM, Ahmed Moustafa Ibrahim Ahmed wrote:

AMIA> The value of each key is an array. And, I want to delete an
AMIA> element of this array. I don't want to delete the whole key. Is
AMIA> it possible?

delete $hash{ key }->[0];

like brett said, perldoc -f delete


AMIA>   - Original Message - 
AMIA>   From: Daniel Gardner 
AMIA>   To: Ahmed Moustafa Ibrahim Ahmed 
AMIA>   Cc: [EMAIL PROTECTED] 
AMIA>   Sent: Tuesday, November 20, 2001 12:50 PM
AMIA>   Subject: Re: How to delete hash element


AMIA>   Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa Ibrahim Ahmed wrote:

AMIA>   AMIA> If I know the key and offset of the element, how can I delete that hash
AMIA>   AMIA> element, please?

AMIA>   you can delete a hash element like:

AMIA> delete $hash{ the_key };

AMIA>   but i'm not sure what you mean by "the offset of the element"



-- 
Best regards,
 Daniel


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




Re[2]: Getting past "Use of uninitialized value..."

2001-11-21 Thread Daniel Gardner

Wednesday, November 21, 2001, 6:35:46 PM, Tomasi, Chuck wrote:

TC> I hate those.  I usually end up creating a log file (or stderr in the case
TC> of web apps) and just print them out to use them again.  Nice debugging, but
TC> needless in some cases.

TC> If you figure a good way use the variable more than once without affecting
TC> the value, I'd like to hear it.

i'm interested - why do you need the variables if you're only using
them once... and what does it matter if you change the value if you're
never going to look at it again?



-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


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




Re: checking if a file exists

2001-11-22 Thread Daniel Gardner

Thursday, November 22, 2001, 2:19:16 PM, [EMAIL PROTECTED] wrote:

GFFC> How would I check if a certain file exists in a certain directory?

GFFC> I'm already using File::Find to process a bunch of mp3's, and before I 
GFFC> move/copy them to a different folder, I want to check if the file already 
GFFC> exists.

you can use the -e operator...

  $file = '/etc/passwd';
  if (-e $file) {
 # the passwd file exists
  }

perldoc -f -X

http://www.perldoc.com/perl5.6.1/pod/func/X.html


-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


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




Re[2]: @_

2001-11-25 Thread Daniel Gardner

Hello Leon,

Monday, November 26, 2001, 12:15:59 AM, Leon wrote:

L> - Original Message -
L> From: "Jenda Krynicky" <[EMAIL PROTECTED]>
L> To: <[EMAIL PROTECTED]>
L> Sent: Monday, November 26, 2001 4:44 AM
L> Subject: Re: @_

>> When you cann a function all the parameters you gave it end up in
>> @_. You can (and usualy do) copy them then into some lexical
>> variables to give them meaningfull names. You don't have to
>> though.

>> If for example <  you wanted to write a function that sums two

L> I like your style, in fact I think everybody should follow Jenda's style of
L> giving an example after an explanation ; an example paints a thousand words.

>> numbers you can write it either as
>> sub add {
>> my ($a, $b) = @_;
>> return $a + $b;
>> }

L> On the above, so what is @_?
L> @_ = ?


if i have code like:

  $result = add( 2, 3 );

then in the code

  sub add {
   my ($a, $b) = @_;
   return $a + $b;
  }

@_ is set to the list (2, 3) just after the "sub add {" line

there's nothing really special about @_, it's the same as any other
array, eg:

  @foo = (1, 2, 3);

isn't special, @_ is just an array who's name is "_", think of the _
like the letter "a" and it might look more comprehensible.

the only special part comes when we're calling a subroutine, where @_
is used to pass the variables into our subroutine.

we could say:

  my @foo = (1,2,3);
  my ($value1, $value2, $value3) = @foo;

and now $value1 == 1, $value2 == 2 and $value3 == 3. so it's the same
when we use @_ at the start of a function.

  my ($a, $b) = @_;

does that make it any clearer?


-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


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




Passwd::Linux

2001-11-25 Thread Daniel Falkenberg

Hi all,

Has any one here had any experience with the Passwd::Linux Cpan module
before?  If you have I would really like to hear from you to get some
ideas. 

Regards,

Dan

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




Simple question

2001-11-25 Thread Daniel Falkenberg

Hey all,

Just a simple question could some one give me a clue as to what the
folling regex will match...

$user = "daniel";

if ( $test =~ /^$user/ ) {
   print "Hello world!\n";
}

Will it match only daniel or will it match dan || danni and so on?

Cheers,

Dan

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




RE: Simple question

2001-11-25 Thread Daniel Falkenberg

No problem.

Thanks for you help.

Dan

-Original Message-
From: Ahmed Moustafa Ibrahim Ahmed [mailto:[EMAIL PROTECTED]]
Sent: Monday, 26 November 2001 3:35 PM
To: [EMAIL PROTECTED]
Subject: Re: Simple question


Sidharth's reply is correct. Mine is not. Sorry for that.

Ahmed Moustafa Ibrahim Ahmed wrote:

> It will match only "daniel". It's the same as: if ($test eq $user).
> Regards,
> Ahmed
> 
> Daniel Falkenberg wrote:
> 
>> Hey all,
>>
>> Just a simple question could some one give me a clue as to what the
>> folling regex will match...
>>
>> $user = "daniel";
>>
>> if ( $test =~ /^$user/ ) {
>>print "Hello world!\n";
>> }
>>
>> Will it match only daniel or will it match dan || danni and so on?
>>
>> Cheers,
>>
>> Dan
> 
> 


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




Any quicker way of writing the following...?

2001-11-26 Thread Daniel Falkenberg

Hey all,

Once again I feel as if the following code is far too long and can
easily be shortened.  Could some one give me some ideas on doing this?

foreach my $U (sort keys %PASS) {
  $PASS{$U}{'fname'} = "";
  $PASS{$U}{'lname'} = "";
  $PASS{$U}{'user'}  = "";
  $PASS{$U}{'password'}  = "";
}

Of coarse all the above does is reset the hash values (%PASS) to equal
nothing.  I am pretty sure I can do this alot easier.]

Also does the following have to be written like so?

$new_user = $PASS{$PASSWD_NAME}{'user'};
$new_pass = $PASS{$PASSWD_NAME}{'password'};
$new_fname= $PASS{$PASSWD_NAME}{'fname'};
$new_lname= $PASS{$PASSWD_NAME}{'lname'};

Do I have to declare each hash value like the above.  Of coarse I want
to be able to still declare a variable to each hash value that I want

Does any one have any ideas on this?

Thx in advance,

Dan

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




  1   2   3   4   5   6   7   >