Re: suidperl?

2006-07-11 Thread Carter Thompson

Take a look at the Win32::AdminMisc, specifically CreateProcessAsUser().

CreateProcessAsUser takes the command line, default directory and an  
optional hash as config options.  If I remember correct (someone feel  
free to correct me) you need to call LogonAsUser() first before using  
CreateProcessAsUser().   Take a look at the faq.

http://www.roth.net/perl/adminmisc/

HTH,

Carter.


On Jul 11, 2006, at 1:52 PM, Bernie Cosell wrote:

 I'm writing a little program that I'd really like to be able to run
 setuid.  Is there some way to do that on XP?   [even something SUDO-
 like would likely be OK [where it'd pop up a box asking for the admin
 pwd].  I can (and, indeed) do do that now in a fairly clumsy way  
 (hence
 my inquiry):

 [How I do it now: I make a shortcut to the program.  Then on the
 shortcut, I hit 'advanced' and then run with different
 credentials.  Then whenever I click on the shortcut I get the
 runasdialogue and can mickeymouse around to put in 'admin'  
 and the
 admin-password.  UGH!  [but it does work]]

   /bernie\

 -- 
 Bernie Cosell Fantasy Farm Fibers
 mailto:[EMAIL PROTECTED] Pearisburg, VA
 --  Too many people, too few sheep  --



 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: mistaken newline

2006-05-20 Thread Carter Thompson


On May 19, 2006, at 10:10 PM, Chris Wagner wrote:


At 05:52 PM 5/19/2006 -0700, $Bill Luebkert wrote:

That's not the problem - he's only changing the first \.


His regex does need the g but he said he was getting output of
C:/path/with\new/content.  All slashes fixed except the one before n.
Carter are u sure u stated ur problem right?  With the regex u  
posted ur
output would be C:/path\with\new\content.  How do u know the \n is  
becoming
a newline?  If perl were interpreting it that way then ur output  
would look

like
C:/path/with
ew/content

The n would be gone and replaced with a linebreak.  If that is indeed
happening then the source of it would be however u are getting that  
line of

data into ur script.  Not anything u do to it later.


The problem is his RE is:
$root =~ s/\\/\//;
and should be:
$root =~ s/\\/\//g;


Yes, you are correct.  The line is printed at one point and I can  
clearly see that
the line is C:/path/with\new/content, but when using this later it  
magically gets

interpreted as a newline.

Thanks to you and $Bill for the assistance.  Fortunately, it appears  
that I merely

needed a 'g' to include all backslashes in the path.

Carter.


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


mistaken newline

2006-05-19 Thread Carter Thompson


Hi,

I've got a script that reads in the contents of a file and then  
parses out the
interesting bits for later use.  One of the interesting bits is a key  
value pair
that's the root to a directory which I'll need to access.  It looks  
like so:



Root:   C:\path\with\new\content

The problem is the part of the path is being interpreted as having a  
newline

in it. (...\new\content).

foreach (@file) {
chomp;
if(/^Root:/) {
m/^Root:\s+(.*)$/;
$root = $1;
$root =~ s/\\/\//;  # change backslash to forward.
}
}

Even after using the substitute backslash to forward slash I still  
end up

with this:

C:/path/with\new/content
 ^^

Any ideas on how to treat the \n as just characters and not a newline?

Thanks!

Carter.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: XML Output to Web

2006-05-10 Thread Carter Thompson


Thanks, Bruno.

I've been using XML::Writer to generate the XML and that works well.   
Problem is I need to
display the generated XML code in a browser.   To display the code  
you generally need to
escape the special characters, like the '  ' (gt, lt amp) which  
is where I have the problem.
XML::Writer creates well formed XML, which is great, but I need to  
create XML for displaying

in a browser.

So, instead of generating this:

projectname=foobardefault=xyzbasedir=. /

I need this:

ltprojectname=foobardefault=xyzbasedir=. /gt

I've looked at most of the modules you've listed but I haven't yet  
found one that generates

escaped XML.

Guess I'll keep looking or write the XML myself.

Thanks again.

Carter.


On May 9, 2006, at 11:20 PM, Bruno Georges wrote:


Hi Carter

I suggest you have a look at the following XML modules:

In your scipt, these module should suffice.

use XML::Parser;
use XML::Simple;
# mod to convert from/to other output
use XML::Dumper;
use CGI::XML;


they should cover the basic XML parsing and generation requierment you
have.

There are other XML modules out of XML:: which are designed to writing
generic XML
XML::Generator
XML::Grove
XML::Writer

I haven't used them much recently but the modules documentation is  
great

and provides plenty of examples.

to get the doc for these modules, you can use for example:
on unix
man XML::Dumper
or on any OS
perldoc

hope this helps.

With Best Regards
Bruno Georges

Glencore International AG
Tel. +41 41 709 3204
Fax +41 41 709 3000


|-+-
| |   Carter Thompson   |
| |   [EMAIL PROTECTED]   |
| |   Sent by:  |
| |   [EMAIL PROTECTED]|
| |   veState.com   |
| | |
| | |
| |   09.05.06 21:28|
| | |
|-+-
- 
-|
   
|  
 |
  |To:  Perl Users perl-win32- 
[EMAIL PROTECTED]
|
  | 
cc:
|
  |Subject: XML Output to  
Web
 |
   
|  
 |
  | 
Distribute:
|
  |Personal?
|---|  
|
  || [ ] x  
|  
|
  | 
|---|  
|
   
|  
 |
- 
-|






Hi,

I need a little help finding a module that will write XML to a
webpage.  More specifically,
I have a CGI script that gathers information based on user input and
when all information
is collected I'd like to spit out XML for the user to cut and paste
into their favorite text editor.

Now, I could write all the special characters (gt, lt, amp, etc)
out to the page but that's
a hassle and I'm fairly certain someone's already done this before.

Any suggestions on what module to use to print XML to my page?

Thanks,

Carter.


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




LEGAL DISCLAIMER. The contents of this e-mail and any attachments  
are strictly
confidential and they may not be used or disclosed by someone who  
is not a

named recipient.
If you have received this email in error please notify the sender  
by replying
to this email inserting the word misdirected as the message and  
delete this

e-mail from your system.



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: XML Output to Web

2006-05-10 Thread Carter Thompson


Wow, that's it?  Thanks, Mark.

Seems to do exactly what I want.

print $q-escapeHTML($xml);

Carter.

On May 10, 2006, at 8:20 AM, Thomas, Mark - BLS CTR wrote:

If character escaping is your only problem, all you have to do is  
this:


use CGI qw/:all/;
print escapeHTML($xml);

--
Mark Thomas
Internet Systems Architect
___
BAE SYSTEMS Information Technology
2525 Network Place
Herndon, VA  20171  USA




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


XML Output to Web

2006-05-09 Thread Carter Thompson


Hi,

I need a little help finding a module that will write XML to a  
webpage.  More specifically,
I have a CGI script that gathers information based on user input and  
when all information
is collected I'd like to spit out XML for the user to cut and paste  
into their favorite text editor.


Now, I could write all the special characters (gt, lt, amp, etc)  
out to the page but that's

a hassle and I'm fairly certain someone's already done this before.

Any suggestions on what module to use to print XML to my page?

Thanks,

Carter.


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: mimic javascript encryption with Javascript::MD5

2006-03-21 Thread Carter Thompson


Take a look at the Digest::MD5 module on CPAN.
http://search.cpan.org/~gaas/Digest-MD5-2.36/MD5.pm

I use it quite a bit in various automation projects I've done.  You  
may be able to adapt

it to your needs.

HTH,

Carter.


On Mar 21, 2006, at 11:28 AM, Hon Shi wrote:


Not trying to do anything nefarious here, just tring to automate some
testing.
Anyways.

I've been using perl's LWP to 'screenscap' and collect data.  We ran
into
a site that uses javascript to hide the user name and login.  The form
has
ist's submit mapped as

   PINPUT id=submit1 name=submit1 type=submit value=Login
  onclick=encryptAndSubmit(); return false;/P

and the javascript function looks like

 function encryptAndSubmit()
   {
  fr = document.forms[0];
  var date = new Date();
  ts = document.getElementById('ts');
  ts.value = date.getTime();
  encrypw = document.getElementById('encrypw');
  encrypw.value =
calcMD5(document.getElementById('password1').value + ts.value );
  if( fr )
 fr.submit();
 }


Is is possible, please show an example, to mimic this using perl
Javascript::MD5
module?  Once we'er past the first page, everything else is just html.

Thanks

xp, perl 5.8, ie6 - I have not used javascript but do know java (if
that helps :-)

update:

There are 6 inputs that I ususally post like this:

 do_POST($url_home,
   [ 'CURRENTSTATE' = 'INITIAL',
 'USERID' = $x_user_id,
 'PASSWORD' = $x_user_password,
 'verb' = 'Login' ]);


with the encryption I assume I have to generate a hash something like
(for the values
listed way above)

---  here's the javascript
 encrypw = document.getElementById('encrypw');
  encrypw.value =
calcMD5(document.getElementById('password1').value + ts.value );

--- perl?
 do_post($url_login_post,
   [ 'ts' = '',
 'encrypw' = '',  #md5 hash here
 'submit1' = '',
 'text1' = '',
 'password1' = '']);

where encrypw will equal a md5 hash?  something like this?

$my_md5 = $md5-calcMD5(password1_val +
time_in_milliseconds_since_1_1_1970);

right track?  Haven't seen anything that looks like the hash method...
yet.

also, the javascript function sets the pasword, in this case encrypw.
Does 'posting' thru lwp fire off the md5 encryption first?

Nothing works ... by-the-way  :-)
Thanks



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



attachment: signature.jpg



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: mySql bat file

2006-03-15 Thread Carter Thompson


Before you start trying to redirect contents to MySQL you'd better check
that you can access MySQL using your user name and password on the
host you intend to script on and don't forget to provide the  
database.  I

find using the longer command line options more useful when debugging.

Such as:

# mysql --database=db --user=username --host=localhost --password

And don't forget that MySQL has built in help.

# mysql --help

Carter.

On Mar 15, 2006, at 7:56 AM, Jerry Kassebaum wrote:

I'm still not able to run a batch file from mysql. Here are my  
latest attempts:


C:\Prog\Perl\MySql\mysqlDocsmysql -u root  go.txt
ERROR 1045 (28000): Access denied for user  
'root'@'localhost' (using password: NO)


C:\Prog\Perl\MySql\mysqlDocsmysql -u localhost -p  go.txt
Enter password: ***
ERROR 1045 (28000): Access denied for user  
'localhost'@'localhost' (using password: YES)


Here is the contents of go.txt: select * from pet;




Jerry Kassebaum wrote:
	 	I'm trying to learn mySql for use with cgi, so I hope y'all will  
consider this close enough to a perl question.


I have a file called perl.dbt that contains a batch file to a  
database. (It should list all the books I've read with Perl in the  
title.)


When I go to the command prompt and enter

mysql  c:\perl\mysql\perl.dbt

I get an error:

ERROR 1045 (28000): Access denied for user  
'ODBC'@'localhost' (using password: NO)


Now what?

Supply a valid user name on the command line, like this:

mysql -u username -p  perl.dbt

This will prompt you for the password (the password must not be  
contained in perl.dbt). To supply the password on the command line,  
write


mysql -u username -ppassword  perl.dbt

Note there is a space between -u and the username but none between - 
p and the password.


Hans


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Threads

2006-02-27 Thread Carter Thompson


Is this really as easy as it seems or am I over looking something?

I have an array with references to tests.  I want to loop through each
element in the array, call a subroutine passing in the test reference
using a thread.   When all tests (threads) have been started I want to
loop through all threads and join so I can retrieve relevant data.

# Start threads.
my @threads = ();
foreach my $ref (@individual_tests) {
$thr = threads-new(\run_test, $ref);
push(@threads, $thr);
}

# Retrieve data
foreach my $thr (@threads) {
my $results = $thr-join();
 }

# run_test sub
sub run_test {
my $ref = shift;

# do stuff in here.

}



Thanks for looking this over.

Carter.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Delta_DHMS

2005-01-04 Thread Carter Thompson


Why doesn't this work?  I expected a diff of 3 seconds but Delta_DHMS
says
I don't have a vaild date.  How can that be?


Perl 5.6.1 on Solaris

#!/usr/bin/perl
#

use strict;
use Date::Calc qw(Delta_DHMS);

  my ($s1, $m1, $h1, $d1, $mn1, $y1, $wday1, $yday1, $isdst1) =
localtime();
  sleep(3);
  my ($s2, $m2, $h2, $d2, $mn2, $y2, $wday2, $yday2, $isdst2) =
localtime();
  my ($days, $hours, $minutes, $seconds) =
Delta_DHMS($y1,$mn1,$d1,$h1,$m1,$s1,
 
$y2,$mn2,$d2,$h2,$m2,$s2);
  print Days: $days, Hours: $hours, Minutes: $minutes, Seconds:
$seconds\n;

Date::Calc::Delta_DHMS(): not a valid date at ./time.pl line 10.

--
Carter A. Thompson

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Delta_DHMS

2005-01-04 Thread Carter Thompson

Duh, nevermind.  I just realized that I forgot to add 1900 to the year
and 1 to the month.

I really coulda used a Christmas vacation. Sigh.

Carter.

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Carter Thompson
 Sent: Tuesday, January 04, 2005 4:47 PM
 To: Perl-Win32-Users
 Subject: Delta_DHMS
 
 
 
 
 Why doesn't this work?  I expected a diff of 3 seconds but 
 Delta_DHMS says I don't have a vaild date.  How can that be?
 
 
 Perl 5.6.1 on Solaris
 
 #!/usr/bin/perl
 #
 
 use strict;
 use Date::Calc qw(Delta_DHMS);
 
   my ($s1, $m1, $h1, $d1, $mn1, $y1, $wday1, $yday1, $isdst1) 
 = localtime();
   sleep(3);
   my ($s2, $m2, $h2, $d2, $mn2, $y2, $wday2, $yday2, $isdst2) 
 = localtime();
   my ($days, $hours, $minutes, $seconds) = 
 Delta_DHMS($y1,$mn1,$d1,$h1,$m1,$s1,
  
 $y2,$mn2,$d2,$h2,$m2,$s2);
   print Days: $days, Hours: $hours, Minutes: $minutes, 
 Seconds: $seconds\n;
 
 Date::Calc::Delta_DHMS(): not a valid date at ./time.pl line 10.
 
 --
 Carter A. Thompson
 
 ___
 Perl-Win32-Users mailing list 
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: problems with DBD::Oracle

2004-12-16 Thread Carter Thompson

John,

I tried a Google for your problem and got this.  I know it's not 
exactly the error your getting but perhaps this will help us narrow 
the problem down.

http://perlmonks.thepen.com/16738.html

Carter.

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of John Deighan
 Sent: Thursday, December 16, 2004 11:12 AM
 To: [EMAIL PROTECTED]
 Subject: RE: problems with DBD::Oracle
 
 
 At 04:50 PM 12/15/2004, Carter Thompson wrote:
 
 John,
 
 Can you run simpler CGI scripts?  I see you've given permissions to 
 Everyone but I wonder if something else (that would be 
 easier to debug) 
 is causing your access denied errors.
 
 I can run CGI scripts, as long as it doesn't try to connect 
 to the Oracle 
 database. However, stand-alone scripts can connect and query 
 just fine. One 
 temporary workaround I found is that I can set up IIS to run under my 
 domain account (the account I'm logged in to when I run stand-alone 
 scripts), so I know that it is indeed a permissions problem. 
 However, I 
 can't figure out what permission I need to give to the IUSR_JDEIGHAN 
 account so that the CGI script will run under that account.
 
   -Original Message-
   From: [EMAIL PROTECTED]
   
 [mailto:[EMAIL PROTECTED] On Behalf 
   Of John Deighan
   Sent: Wednesday, December 15, 2004 12:59 PM
   To: [EMAIL PROTECTED]
   Subject: problems with DBD::Oracle
  
  
   I'm trying to get my web site working with an Oracle 
 database (I've 
   been using SQL Server through DBD::ODBC). Although stand alone 
   scripts can successfully access the remote Oracle 
 database, my web 
   site, running under
   IIS, can't. I get a 500 server error, and in the Perl log 
 file, I get:
  
   *** 'c:\wwwroot\empty\default.plx' log message at: 2004/12/15 
   15:53:06
   Precompiler: CORE::require failed $@ = 'Can't load
   'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module 
 DBD::Oracle:
   load_file:Access is denied at C:/Perl/lib/DynaLoader.pm line 229.
 at (eval 95) line 3
   Compilation failed in require at (eval 95) line 3.
   ' result = ''
   Precompiler: Execute Error:
 Filename:[c:\wwwroot\empty\default.plx]
 
 Package:[PerlEx::Precompiler::c_::wwwroot::empty::default_plx]
   Params[]
   DbConn: Unable to open database connection for user 
 'easyiep' source
   'LocalServer'install_driver(Oracle) failed: Can't load
   'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module 
 DBD::Oracle:
   load_file:Access is denied at C:/Perl/lib/DynaLoader.pm line 229.
 at (eval 95) line 3
   Compilation failed in require at (eval 95) line 3.
   Perhaps a required shared library or dll isn't installed
   where expected
 at c:/PerlLibs/DbConn.pm line 62
  
  
   I've taken the DLL mentioned, and given full control to Everyone, 
   SYSTEM, and IUSR_JDEIGHAN (the account that my web site is running
   under). Can
   anyone figure out what's wrong?
  
   OS: Microsoft Windows 2000 Server
   Perl: ActivePerl 5.8.3
   DBI: 1.46
   DBD-Oracle: 1.12
  
   ___
   Perl-Win32-Users mailing list 
   [EMAIL PROTECTED]
   To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: problems with DBD::Oracle

2004-12-15 Thread Carter Thompson

John,

Can you run simpler CGI scripts?  I see you've given permissions to 
Everyone but I wonder if something else (that would be easier to debug)
is causing your access denied errors.

Carter.


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of John Deighan
 Sent: Wednesday, December 15, 2004 12:59 PM
 To: [EMAIL PROTECTED]
 Subject: problems with DBD::Oracle
 
 
 I'm trying to get my web site working with an Oracle database 
 (I've been 
 using SQL Server through DBD::ODBC). Although stand alone scripts can 
 successfully access the remote Oracle database, my web site, 
 running under 
 IIS, can't. I get a 500 server error, and in the Perl log file, I get:
 
 *** 'c:\wwwroot\empty\default.plx' log message at: 2004/12/15 15:53:06
 Precompiler: CORE::require failed $@ = 'Can't load 
 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: 
 load_file:Access is denied at C:/Perl/lib/DynaLoader.pm line 229.
   at (eval 95) line 3
 Compilation failed in require at (eval 95) line 3.
 ' result = ''
 Precompiler: Execute Error:
   Filename:[c:\wwwroot\empty\default.plx]
   Package:[PerlEx::Precompiler::c_::wwwroot::empty::default_plx]
 Params[]
 DbConn: Unable to open database connection for user 'easyiep' source 
 'LocalServer'install_driver(Oracle) failed: Can't load 
 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: 
 load_file:Access is denied at C:/Perl/lib/DynaLoader.pm line 229.
   at (eval 95) line 3
 Compilation failed in require at (eval 95) line 3.
 Perhaps a required shared library or dll isn't installed 
 where expected
   at c:/PerlLibs/DbConn.pm line 62
 
 
 I've taken the DLL mentioned, and given full control to 
 Everyone, SYSTEM, 
 and IUSR_JDEIGHAN (the account that my web site is running 
 under). Can 
 anyone figure out what's wrong?
 
 OS: Microsoft Windows 2000 Server
 Perl: ActivePerl 5.8.3
 DBI: 1.46
 DBD-Oracle: 1.12
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


XML::Writer troubles

2004-12-01 Thread Carter Thompson

Hi All,

I got some pretty strange problems using XML::Writer where the file that
I'm
writing to ends up with almost twice the data that I'm trying to write.
I'll
try to make a simple example (in the order of operation) since the code
I'm 
using is quite long. 

 In Init.pm I have something like this: 

use strict;
use IO;
use POSIX qw(strftime);
use XML::Writer;

my $log = /usr/builds/bldlog.xml;
my $xmllog = new IO::File( $log);
my $writer = new XML::Writer(OUTPUT = $xmllog, DATA_MODE = 'true',
DATA_INDENT = 2);
$writer-xmlDecl('UTF-8');
$writer-comment(Build Log);
$writer-startTag('Build');
my $time = strftime %m-%d-%Y %H:%M:%S, localtime;
$writer-dataElement(Time,$time);

return ($writer);

 In Main.pl I have this 

my $xmlwr = Init();
Display($xmlwr);
SRC($xmlwr);
...

 In Display.pm I have this 

$writer-startTag('Display');
$writer-startTag('Variables');
foreach my $key (sort keys %hash) {
$writer-dataElement($key,$hash{$key});
}
$writer-endTag('Variables');
$writer-endTag('Display');

 In SRC.pm I have the final stage 

$writer-startTag('CVS');
$writer-dataElement(Tag,$TAG);
$writer-startTag('Files');
open(CVS,  $cvslog);
while(CVS) {
$writer-characters($_);
}
close(CVS);
$writer-endTag('Files');
$writer-endTag('CVS');

 END 
?xml version=1.0 encoding=UTF-8?
!-- Build Log --
Build
  Time12-01-2004 14:06:36/Time
  Display
Variables
  ARGSblah/ARGS
  NUM27/NUM
/Variables
  /Display?xml version=1.0 encoding=UTF-8?  !!
!-- Build Log --
Build
  Time12-01-2004 14:06:36/Time
  Display
Variables
  ARGSblah/ARGS
  NUM27/NUM
/Variables
  /Display
  CVS
Tagsuite-test-build-27/Tag
 FilesU suite/ant_include.xml
U suite/build.pb_to_bin.sh
U suite/build.properties
U suite/build.xml
/Files
  /CVS

As you can see above the xml is started again after the end Display tag.
I realize that I don't have an end tag but that shouldn't matter, should
it?
The time between the end Display tag is written and the CVS tag is
approximately
40 minutes while a rather long process runs gathering data.  I don't
know if
that would matter much.  Any help is appreciated.  Sorry for being so
long 
winded I just wanted to make this as clear as possible.

Thanks!

Carter.



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: UNIX utilities in Perl

2004-11-10 Thread Carter Thompson

Martin,

I suggest that you look at cygwin http://www.cygwin.com/ for a
Unix/Linux
like environment on Windows.  All the commands you've mentioned are
available as precompiled windows binaries. 

Alternatively, you could also try MKS Toolkit http://www.mks.com/ but
it's 
not free and in my opinion not worth the expense.

Cheers,

Carter.

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Martin Leese
 Sent: Wednesday, November 10, 2004 10:40 AM
 To: [EMAIL PROTECTED]
 Subject: UNIX utilities in Perl
 
 
 Hi,
 
 I am not sure if this is the right list for this question.
 I suspect it belongs on a list about CPAN, but the CPAN
 site doesn't appear to mention one.
 
 I am working on Windows, and find I keep writing very
 short Perl scripts to implement UNIX utilities.  I call
 them zap_grep, zap_wc, zap_unique, zap_diff, zap_sort.
 My versions are very crude compared with the UNIX
 originals, and I wondered if somebody had already gone
 through this exercise.
 
 A search of CPAN came up with prep (Perl grep), wc,
 and uniq.
 Are these modules collected together anywhere?
 Should they be?
 What additional UNIX utilities would be useful?  (Above,
 I suggest diff and sort.)
 
 What would be *really* useful is a method to pipe
 filters together.
 
 Regards,
 Martin
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: date question

2004-10-12 Thread Carter Thompson

Lori,

I'm not that familar with Postgresql, however you should check out
the online documentation on SQL Functions and roll your own.  Here's
the link to the page.

http://www.postgresql.org/docs/aw_pgsql_book/node164.html

Several of the examples appear to be close to what I think you're
looking for in a function.

Cheers,

Carter.


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Lori
 Sent: Tuesday, October 12, 2004 2:29 PM
 To: [EMAIL PROTECTED]
 Subject: date question
 
 
 This is a postgresql question , slam me if you must, but this is the 
 only list where I get a
 fast response and I know many of you use postgresql 
 
 I have a int field called when_month and I want to use it to get the 
 full month name
 something like :
  update  mytable set myfield = date_part(month,'1/5/2004');
  the problem is date part returns 5 not May
 
  If I wanted to do this in a program I could easily do it with an 
 array ,but cant find quick way to do in postgresql ?
 
 I have looked it up on the postgresql site and on google but 
 cant find a 
 simple function that will do the trick
 
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Need help on usage of sendmail in Windows 2000 Server

2004-10-08 Thread Carter Thompson


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of $Bill Luebkert
 Sent: Thursday, October 07, 2004 9:49 PM
 To: Uma Chandrsekaran
 Cc: [EMAIL PROTECTED]
 Subject: Re: Need help on usage of sendmail in Windows 2000 Server
 
 
 Uma Chandrsekaran wrote:
 
  Hi
  
  I tried this script for sending mail in Windows 2000 Server, but it 
  failed.
  
  use Mail::Sendmail;
  
  %mail = ( To  = '[EMAIL PROTECTED]',
From= '[EMAIL PROTECTED]',
Message = This is a very short message
  );
  sendmail(%mail) or warn $Mail::Sendmail::error;
  
  Look like these set of commands are not getting executed as I not 
  getting any mail  it also doesnot give me any error message.
  
  Your input on this would be highly appreciated.
 
 I would use Net::SMTP for simple messages or MIME::Lite 
 (which also uses Net::SMTP) for more complicated email needs 
 (attachments etc).


You can certainly use the Net::SMTP or MIME::Lite as $Bill has 
recommended above, but if you want to stick with Mail::Sendmail you'll
need to do a couple of things.

First, make sure you use a backslash before the @ in the email
addresses.
Second, you need to specify your smtp Mail Server that will handle your 
request. And lastly, you should print the Mail::Sendmail::error when
things fail, in fact you can use Mail::Sendmail::log to get the result
of
your attempt.  Here's an example for you to play with.

use strict;
use Mail::Sendmail;

  my $msg = This is a very short message\n;
  my $priority  = High;
  my $Subject = Mail::Sendmail Example;
  my $To  = Some User
\[EMAIL PROTECTED],;
  my $From= You \[EMAIL PROTECTED];
  my $MailServer= smtp-mailserver.someplace.com;
  my %mail;

  unshift @{$Mail::Sendmail::mailcfg{'smtp'}} , $MailServer;
  %mail = ('To'   = $To,
   'From'  = $From,
   'Subject'   = $Subject,
   'Message'   = $msg,
   'Importance'= $priority,
   'X-Mailer'  = 'Mail::Sendmail version
$Mail::Sendmail::VERSION',
   );
  sendmail(%mail) or die $Mail::Sendmail::error;
  print SendMail Log says:\n, $Mail::Sendmail::log;
  print \n;


Good Luck.

Carter.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: The old \015 problem

2004-10-07 Thread Carter Thompson


A really easy way is to use dos2unix.  It'll take care of the CRs.

Carter.



 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of David D Miller
 Sent: Thursday, October 07, 2004 2:35 PM
 To: [EMAIL PROTECTED]
 Subject: The old \015 problem
 
 
 
 
 
 
 Folks
 
 I just copied (using ftp in binary mode) my perl scripts from 
 DOS to Unix and got caught on the carriage return problem:  
 When I try to execute the DOS scipt in Unix, I get the following
 
 [mdscom]/usr/people/dmiller/WWW/cgi perl wtdl.pl -w
 Illegal character \015 (carriage return) at wtdl.pl line 5. 
 (Maybe you didn't strip carriage returns after a network transfer?)
 
 Good message.  Right on target.  The question is, how do I 
 remove those pesky CRs?
 
 dave.
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: The old \015 problem

2004-10-07 Thread Carter Thompson

Dave,

dos2unix isn't part of the Perl distribution.  My version of 
dos2unix (installed on solaris) lives in /bin. If for some 
reason you don't have an installed version of dos2unix try 
this web page to do your conversion:

http://www.iconv.com/dos2unix.htm

Cheers,

Carter.


 -Original Message-
 From: David D Miller [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, October 07, 2004 3:06 PM
 To: Carter Thompson
 Cc: [EMAIL PROTECTED]
 Subject: RE: The old \015 problem
 
 
 
 
 
 
 Carter:
 
 Where do I find this wonderful little tool?  I looked for it 
 on DOS and Unix without any luck.  Not part of the perl 
 delivery I guess.
 
 dave.
 
 
 
 
 A really easy way is to use dos2unix.  It'll take care of the CRs.
 
 Carter.
 
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] 
 On Behalf 
  Of David D Miller
  Sent: Thursday, October 07, 2004 2:35 PM
  To: [EMAIL PROTECTED]
  Subject: The old \015 problem
 
 
 
 
 
 
  Folks
 
  I just copied (using ftp in binary mode) my perl scripts 
 from DOS to 
  Unix and got caught on the carriage return problem: When I try to 
  execute the DOS scipt in Unix, I get the following
 
  [mdscom]/usr/people/dmiller/WWW/cgi perl wtdl.pl -w
  Illegal character \015 (carriage return) at wtdl.pl line 5. 
 (Maybe you 
  didn't strip carriage returns after a network transfer?)
 
  Good message.  Right on target.  The question is, how do I remove 
  those pesky CRs?
 
  dave.
 
  ___
  Perl-Win32-Users mailing list 
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 
 
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: XML Out.

2004-09-23 Thread Carter Thompson

Pratibha,

Thank you for the example.  I will definitely be making use of it.

On a similar note, what would be the best way to read the patches.xml
file in and add or make changes to the content and write it back out?
Read with XML::Simple, then write out with XML::Writer?  Or is their 
a more efficient method of doing this?

Many thanks!

Carter.


 -Original Message-
 From: pratibha sharma [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, September 23, 2004 1:11 PM
 To: Carter Thompson; [EMAIL PROTECTED]
 Subject: RE: XML Out.
 
 
 Hi Carter,
 
 
 Following is the example to the generate patches.xml using XML:Writer
 
 
 Pratibha
 
 --
 --
 
 #!/usr/local/bin/perl
 
 use IO;
 use XML::Writer;
 my $patchXMLFile = new IO::File(.\\patches.xml);
 
 
 my $description= This is a xml generattion example using 
 XML::Writer; my $xmlWriter = new XML::Writer(OUTPUT = 
 $patchXMLFile, DATA_MODE = 
 'true', DATA_INDENT = 2);
 
 $xmlWriter-xmlDecl('UTF-8', 'standalone' = 'yes');
 
 $xmlWriter-startTag('patches'); 
 $xmlWriter-startTag('product-release');
 $xmlWriter-dataElement(version, 1.0); 
 $xmlWriter-startTag('patch'); 
 $xmlWriter-dataElement(number, 1); 
 $xmlWriter-dataElement(readme, 1.0.0.1-readme); 
 $xmlWriter-dataElement(file, 1.0.0.1-tar.gz); 
 $xmlWriter-startTag('desc'); $xmlWriter-characters($description);
 $xmlWriter-endTag();
 $xmlWriter-endTag();
 $xmlWriter-endTag();
 
 $xmlWriter-startTag('product-release');
 $xmlWriter-dataElement(version, 2.0); 
 $xmlWriter-startTag('patch'); 
 $xmlWriter-dataElement(number, 1); 
 $xmlWriter-dataElement(readme, 2.0.0.1-readme); 
 $xmlWriter-dataElement(file, 2.0.0.1-tar.gz); 
 $xmlWriter-startTag('desc'); $xmlWriter-characters($description);
 $xmlWriter-endTag();
 $xmlWriter-endTag();
 $xmlWriter-endTag();
 $xmlWriter-endTag();
 $xmlWriter-end();
 
 
 
 
 
 Hi All,
 
 I've just been given my first pure XML project.  It involves reading 
 and writing an xml file of software patches.  In the past I've used 
 XML::Simple to read the patch file and obtain the data I'm 
 interested 
 in, however I've
 now become the owner of the file and I now need to insert 
 new data into
 the patches.xml file.  After reading a bit on XML::Simple it appears
 that
 I can not use XMLout() to write contents in an ordered fashion so I'm
 hoping someone can help with a suggestion and example of 
 what to use to
 write another record into my patches.xml file.  It looks like this:
 
 Example:
 
 patches
  product-release
  version1.0/version
  patch
  number1/number
  readme1.0.0.1-readme/readme
  file1.0.0.1-tar.gz/file
  desc
  Description
  /desc
  /patch
  /product-release
  product-release
  version2.0/version
  patch
  number1/number
  readme2.0.0.1-readme/readme
  file2.0.0.1-tar.gz/file
  desc
  Description
  /desc
  /patch
  /product-release
 /patches
 
 I've looked at XML::DOM, XML::TreeBuilder and several others but I'm 
 really looking for the easiest and fastest to implement this.
 
 Any help and/or tips is appreciated.
 
 Cheers,
 
 Carter.
 
 
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: XML Out.

2004-09-23 Thread Carter Thompson

Mark,

You're absolutely right.  I didn't mention that I wanted to add a new
patch node, fortunately for me you assumed correctly.  

To answer your question on XML::Simple, I've used it to grab data from
the patches.xml file but not to write it out.  After reading the
documentation
on XML::Simple I learned that the order is lost once you've read the XML
into a hashref.  I was hoping to keep the order.  Hence my reason for
not
using XML::Simple to write the hashref back out to a file.

Of all your examples I think I like the XML:LibXML one the best.  It
seems
to fit with what I'm doing here.  Although, before I do anything with it
I'll
take a look at Class::XML, sounds interesting.

Thanks, Mark.

Carter.


 -Original Message-
 From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED] 
 
 Carter, you didn't say what you wanted to add, and where. 
 I'll make the assumption you want to add a sibling patch 
 node to release version 2.0. Here are a few options:
 
 OPTION 1
 Take another look at XML::Simple. I don't see anything in 
 your XML that wouldn't be possible to create using 
 XML::Simple. Did you use the KeyAttr and ForceArray options?
 
 With your sample XML, the following code:
 
   use XML::Simple;
   my $xs = XML::Simple-new(KeepRoot=1, ForceArray=1, KeyAttr=[]);
   my $ref = $xs-XMLin($xml);
   print $xs-XMLout($ref);
 
 reads it in and prints an XML document equivalent to the input.
 
 OPTION 2
 If you're comfortable with OO, and maybe a little 
 adventurous, you may want to look at the new module 
 Class::XML. This is supposed to allow you to treat your XML 
 as objects. You do some upfront work including creating a 
 couple small packages representing your XML constructs (Patch 
 and ProductRelease). If you also add a relation called 
 get_release, adding a patch might be something like this 
 (completely untested code from a skim of the docs--consider 
 it pseudocode):
 
   my $new_patch = Patch-new;
   $new_patch-number(2);
   $new_patch-readme('readme-2.txt');
   $new_patch-file('patchfile.gz');
   $new_patch-desc('Description');
   
   my ($latest_release) = ProductRelease-get_release(2.0);
   $latest_release-patch($new_patch);
 
 OPTION 3
 DOM's not hard when you are very familiar with the structure 
 of the XML. Here's sample XML::LibXML code that adds a new 
 patch to release 2.0 (tested).
 
 use XML::LibXML;
 my $patches = XML::LibXML-new-parse_file('patches.xml');
 my ($release) = 
 $patches-findnodes('//[EMAIL PROTECTED]2.0]');
 
 my $new_patch= XML::LibXML::Element-new('patch');
 $new_patch-appendTextChild('number','2');
 $new_patch-appendTextChild('readme','readme-2.txt');
 $new_patch-appendTextChild('file','patchfile.gz');
 $new_patch-appendTextChild('desc','Description');
 
 my ($release) = 
 $patches-findnodes('//product-release[version=2.0]');
 $release-appendChild($new_patch);
 
 print $patches-toString(1); #or $patches-toFile($filename);
 
 
 -- 
 Mark Thomas[EMAIL PROTECTED] 
 Internet Systems Architect DigitalNet, Inc. 
 
 $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; 
 ;y;y; ;;print;; 
   
 
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Using use module in multiplatform environment.

2004-07-06 Thread Carter Thompson


I have a script that is utilized on both Solaris and Windows.
In the Solaris environment I use fork() to create a separate
process, in the Windows environment I use Win32::Process. This
unfortunately creates a bit of a problem when I attempt to 
run the script on Solaris since the compiler attempts to find
the Win32 modules I've used.  What's the easiest way to 
implement this?  I've already checked into autouse and require.

Thanks!

Carter.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Using use module in multiplatform environment.

2004-07-06 Thread Carter Thompson

Thanks to all for the help!  I have the problem fixed with a 
minimum of change.

if($^O eq MSWin32) {
require Win32;
require Win32::Process;
Win32::Process-import(qw(NORMAL_PRIORITY_CLASS));
}

Cheers,

Carter.

 -Original Message-
 From: Mike Jackson [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, July 06, 2004 1:57 PM
 To: Carter Thompson; Perl-Win32-Users
 Subject: Re: Using use module in multiplatform environment.
 
 
 check your platform somehow, and make modules for each that 
 expose a common interface, so you can pull one out and drop 
 in the other with a minimum of fuss.
 
 you could then eval{} the correct one, or put them in 
 separate files and do() the filename. both of these are 
 somewhat similar to the use keyword, and in your circumstance 
 provide pretty much what you're looking for.
 
 if both expose the same methods, you now have a fork() call 
 that works transparently under solaris and win32.
 
 
 
 On Tue, 6 Jul 2004 13:35:49 -0700, Carter Thompson 
 [EMAIL PROTECTED] wrote:
 
 
 
  I have a script that is utilized on both Solaris and 
 Windows. In the 
  Solaris environment I use fork() to create a separate 
 process, in the 
  Windows environment I use Win32::Process. This 
 unfortunately creates a 
  bit of a problem when I attempt to run the script on 
 Solaris since the 
  compiler attempts to find the Win32 modules I've used.  
 What's the 
  easiest way to implement this?  I've already checked into 
 autouse and 
  require.
 
  Thanks!
 
  Carter.
 
 
  ___
  Perl-Win32-Users mailing list 
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Inner Join using win32:odbc

2004-06-30 Thread Carter Thompson

Eugene,

This might help you.  This is completely untested but should get you
on the right track.  It may also be necessary for you to modify the
SQL since I am not that familiar with MS SQL Server.

Cheers,

Carter.

-= Untested Code =-

use Win32::ODBC;

# Establish a connection.
my $db = new Win32::ODBC(DSN=YourDSN;UID=you;PWD=password)
or die Win32::ODBC::Error();

# Prepare and execute the statement
my $SQL = SELECT requestInfo.*, comments.* FROM requestInfo, comments
WHERE requestInfo.refnum = comments.refnum = '86';
if ($db-Sql($SQL)) {
print SQL Error:  . $db-Error() . \n;
$db-Close();
exit;
}

# Fetch Data
while ($db-FetchRow) {
my @row = $db-Data();
# do something with @row.
}

# Disconnect from DB.
$db-Close();




 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Watts, Eugene P, WCS
 Sent: Wednesday, June 30, 2004 11:37 AM
 To: [EMAIL PROTECTED]
 Subject: Inner Join using win32:odbc
 
 
  I am beginner in Perl running Perl v5.6.1.633 with win32::odbc on a 
  Windows 2000 server.  I am trying to pull all of the data 
 from two tables using a match on a particular column where 
 from two table when they contain a particular value (inner 
 join).  The tables are on an Windows 2000 SQL server.  I am 
 having trouble with the SQL syntax.
  
  I can pull all of the data from both tables using the perl scripts 
  below.
  
  For table requestInfo
  
  $db-Sql( SELECT * FROM requestInfo WHERE (refnum == 86)) 
  {
  ..Do something.
  
  }
  $db-Close();
  
  For table comments
  
  $db-Sql( SELECT * FROM comments WHERE (refnum == 86)) 
  {
  ..Do something.
  
  }
  $db-Close();
  
  A column called refnum (integer) is in both tables.  Sample 
 code and 
  examples would be a big help.
  
  Thanks in advance for your help.
  
  Eugene P. Watts
Watts, Eugene P, ALINF.vcf
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: fork() and wait().

2004-05-20 Thread Carter Thompson

Thanks, Tony.

I'm using 5.6.1 primarily on Solaris, however the work that I'm
doing should eventually end up in a Perl Module that I will use
on Win32 platforms and Unix platforms.  I understand that 
Win32::Process will handle this on Win32 platforms but that doesn't
much help me with Unix implementations.  Therefore, I could *really*
use a good example of how to implement wait and waitpid.

Thanks again.

Carter.


 -Original Message-
 From: Tony White [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, May 20, 2004 9:14 AM
 To: Carter Thompson; Perl-Win32-Users
 Subject: RE: fork() and wait().
 
 
 What version of Perl are you using?  If you're using 5.8.0 or 
 above, fork() works like the threads pragma does.  Take a 
 look at perlfork and/or the threads and threads::shared 
 Pragmas.  Oh yeah, and especially perlthrtut and perlothrtut. 
  All these can be found in the ActivePerl User Guide.  
 They're very good and will help you get started (although 
 you'll spend a couple of hours reading, maybe).
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  
 [mailto:[EMAIL PROTECTED] 
 Behalf Of 
  Carter Thompson
  Sent: Wednesday, May 19, 2004 6:14 PM
  To: Perl-Win32-Users
  Subject: fork() and wait().
  
  
  
  
  I checked the archives on how to implement a fork() where
  I can run a child process (system call) and wait until the
  child ends while processing other stuff and came up with 
  this gem:
  
   Depending on your exact requirements, you may be able to
  achieve what
  you
   want by simply starting the application with a system call. Perl 
   will then wait for that system command to run to completion
  before
   continuing on with the rest of the script.
   Which is all very well if you simply want the script to start a
  process and
   then wait for that process to finish before continuing on.
  
   But if you want the script to fork a process, then do some
  more stuff
  (while
   the process is running), and then wait for the forked process to
  complete
   before it continues, you can do this with a 'wait();' call at the
  point at
   which you want the parent script to wait.
   
   (Check out the 'wait' and 'waitpid' functions in the docs).
  
   Cheers,
   Rob
  
  This is exactly what I want to do, however I'm still not sure
  how to use
  wait()
  or waitpid even after checking the docs.
  
  == psuedo code ==
  
  $child = fork() || die Can't fork: $! unless defined $child;
  
  if($child  0) { #parent process
  # print dots until command finishes.
  do {
  print .;
  waitpid();
  }
  } else {# child process
  my $ppid = getppid();
  $result = system(command);
  }
  
  == end psuedo code ==
  
  OK, I know that doesn't work but it should give you a 
 pretty good idea 
  of what I'm trying to achieve.
  
  Thanks,
  
  Carter.
  
  
  ___
  Perl-Win32-Users mailing list 
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32 - Browse for files.

2004-05-13 Thread Carter Thompson

Thanks, Dirk, Bill, and Glenn,

That's definitely what I wanted.  I'll have to learn a bit more about
programming Win32 Gui's though, I primarly work on Linux/Unix and the
Win32 stuff seems a bit odd.

Cheers,

Carter.

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Dirk Bremer (NISC)
 Sent: Thursday, May 13, 2004 6:09 AM
 To: Perl-Win32-Users
 Subject: Re: Win32 - Browse for files.
 
 
 
  Hi,
 
  I have a need to create a small app for our support
 organization which
  primarily uses Windoze to do their day to day tasks.  Since
 they are
  not that command line savy I'd like to put together something that
  allows them to push a button or two to get their file(s) 
 uploaded to
  various locations.
  Having used Perl/Tk in the past I know it's pretty straight forward 
  using something like a ComboBox or other widget to get the visual
 stuff done.
 
  This time I'd like to try to put something together that appears a 
  little more native and not having a lot of Win32::GUI, Win32::API 
  experience I need some help getting started.  Can someone 
 help me with 
  a explorer type
  control that would allow a user to navigate to a file?  I 
 can probably
  take it from there.
 
  Many Thanks!
 
  Carter.
 
 Carter,
 
 I had the same requirement and used the following code:
 
 use Win32::FileOp;
 
 # Solicit the user via a dialog box to select the files to be 
 processed.
 @Files = Win32::FileOp::OpenDialog(-title   = Select 
 File(s) to process,
-filters = ['All Files' = '*.*'],
-defaultfilter = 1,
-dir = 'c:\\',
-filename = '*.*',
-options = 
 OFN_ALLOWMULTISELECT | OFN_EXPLORER);
 
 Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. 
 Peters USA Central Time Zone 636-922-9158 ext. 8652 fax 636-447-4471
 
 [EMAIL PROTECTED]
 www.nisc.cc
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: CSV munging and uninitialized values

2003-08-14 Thread Carter Thompson

Terry, look for range operators.

Important to note that .. differs from 

.. returns true is both tests are true.
... doesn't return true if both tests are true.

You can use them with patterns or line numbers.

Cheers,

Carter.


 -Original Message-
 From: Terry Fowler [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 12, 2003 10:03 AM
 Cc: [EMAIL PROTECTED]
 Subject: Re: CSV munging and uninitialized values
 
 
 $Bill Luebkert wrote:
  
  for (@line .. 41) {
  $line[$_] = '';
  }
 
 I've seen this use of .. only a few times before and
 don't really know what it's all about. I don't even 
 know what to look for in the Llama book - them two dots?
 
 Terry Fowler
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Installing XML::Parser

2003-08-11 Thread Carter Thompson

Rex,


Perhaps using CPAN might get you around the problem.  

Assuming you have CPAN installed and configured:

perl -MCPAN -e 'install XML::Parser'

Cheers,

Carter.

 -Original Message-
 From: Arul, Rex [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, August 06, 2003 12:01 PM
 To: [EMAIL PROTECTED]
 Subject: Installing XML::Parser
 
 
 I am having a weird problem upgrading to the recent version 
 of XML::Parser.
 Through PPM, I gave a 'ppm verify --upgrade XML::Parser' 
 command and it
 waits for some time, does nothing (not even an error message) and then
 exits. When I issue a query, the old version is what exists 
 (2.27). So, I
 thought I would remove it and install it afresh, because my PPM SEARCH
 command shows an updated one available (2.31). However, when 
 I try removing
 it,it says PPM needs this module and hence you cannot remove it.
 
 I am in a Catch-22 situation. Any words of wisdom would be gratefully
 received.
 
 Thanks in advance,
 Rex
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32 Dialog

2003-07-29 Thread Carter Thompson


Many thanks, John.

It turned out that the environment just got weird.  I rebooted
my machine and everything started working.  I hate problems 
like that when you're trying learning something new and 
unfamiliar.

Cheers,

Carter.


 -Original Message-
 From: Huber. John (PWA) [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, July 29, 2003 1:08 PM
 To: Carter Thompson; Perl-Win32-Users (E-mail)
 Subject: RE: Win32 Dialog
 
 
 I just added the name parameter to your code and it worked 
 ok. The sleep
 at the end is just so you can see the window.
 
 use Win32::GUI;
 
 my $winobj = Win32::GUI::Window-new(
   -name= Window,
   -minwidth   = 10, 
   -minheight  = 10, 
   -maxwidth   = 100, 
   -maxheight  = 100);
 $winobj-Show();
 sleep 10;
 
 john
 
 -Original Message-
 From: Carter Thompson [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, July 29, 2003 12:02 PM
 To: Perl-Win32-Users (E-mail)
 Subject: Win32 Dialog
 
 
 
 
 I have a need to generate a small Win32 dialog to display some
 information graphically.  I have experience writing Perl/Tk
 gui's so I thought this would be pretty straight forward,
 unfortunately this is not the case.  Given the example below
 shouldn't this snippet display an empty dialog? 
 
 =-=-=-=
 use Win32::GUI;
 
 my $winobj = Win32::GUI::Window-new( -minwidth = 10, 
   -minheight =
 10, 
   -maxwidth =
 100, 
   -maxheight =
 100);
 $winobj-Show();
 =-=-=-=
 
 I get the following error when I attempt to run it:
 
 Scalar found where operator expected at Win32/GUI.pm line 1588, near
 $max $::sspb_lno
   (Missing operator before $::sspb_lno?)
 Scalar found where operator expected at Win32/GUI.pm line 
 1667, near $y
 $::sspb_lno
   (Missing operator before $::sspb_lno?)
 Scalar found where operator expected at Win32/GUI.pm line 1588, near
 $max $::sspb_lno
   (Missing operator before $::sspb_lno?)
 Scalar found where operator expected at Win32/GUI.pm line 
 1667, near $y
 $::sspb_lno
   (Missing operator before $::sspb_lno?)
 syntax error at Win32/GUI.pm line 1588, near $max $::sspb_lno
 syntax error at Win32/GUI.pm line 1667, near $y $::sspb_lno
 Compilation failed in require at script line 6.
 BEGIN failed--compilation aborted at script line 6.
 
 Obviously, my use of Win32::GUI isn't correct, so if I 
 change the code
 to
 the following:
 
 =-=-=-=
 use Win32::GUI::Window;
 
 my $winobj = Win32::GUI::Window-new( -minwidth = 10, 
   -minheight =
 10, 
   -maxwidth =
 100, 
   -maxheight =
 100);
 $winobj-Show();
 =-=-=-=
 
 I get this error:
 
 Can't locate Win32/GUI/Window.pm in @INC (@INC contains: C:/Perl/lib
 C:/Perl/site/lib .) at script line 6.
 BEGIN failed--compilation aborted at script line 6.
 
 
 What am I doing wrong and/or missing?
 
 Thanks!
 
 Carter.
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Client/Server IO::Socket

2003-02-26 Thread Carter Thompson

I need some help with writing a client and server.   I'm relatively new
to IO::Socket and socket programming so be gentle.  ;-)

Here's what I've done thus far with the Server:

=-=-=-=-=-=-=-=-=-=-=-=
#!C:/Perl/bin/perl.exe
#
use strict;
use IO::Socket qw(:DEFAULT :crlf);
use POSIX 'WNOHANG';

use constant PORT = 5150;

my $quit = 0;
$SIG{CHLD} = sub { while (waitpid(-1,WNOHANG)0) {}};

$SIG{INT} = sub { $quit++ };

my $listen_socket = IO::Socket::INET-new(LocalPort =  PORT,
Listen 
 = 20,
Proto  
 = 'tcp',
Reuse  
 = 1,

Timeout = 60*60,
);
die Can't create listening socket: $@ unless $listen_socket;
warn Server Ready. Waiting for connections...\n;

while (!$quit) {
next unless my $connection = $listen_socket-accept();

my $peer = gethostbyaddr($connection-peeraddr,AF_INET) || 
$connection-peerhost;
my $port = $connection-peerport;
warn Connection from [$peer, $port]\n;

defined(my $child = fork()) or die Can't fork: $!;
if($child == 0) {
$listen_socket-close();
interact($connection);
exit 0;
}
warn Connection from [$peer, $port] finished\n;
$connection-close();
}

sub interact {
my $sock = shift;

# What do I do here to get STDOUT, STDERR?

close $sock;
}   
=-=-=-=-=-=-=-=-=-=-=-=

I can connect to the socket using telnet and see the connection created but
it ends immediately and I can't input anything (cause the connection ends and
I don't have anything to handle the input anyway).

How can I connect to the socket and issue commands to the server?  Like dir
or any other OS command?

Sorry this is long winded.

Thanks for the assistance.

Carter.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [PMX:#] DBI SQL 2000 driver

2003-02-26 Thread Carter Thompson


Yes, I am doing this currently.

This chunk of code comes from a CGI script that I use to retrieve data
from the SQL database.  I pre-create the SQL Statement that I want to
use and pass it in as a string, for example; 

my $SQL = SELECT foo FROM MYTABLE WHERE id=1;
my @returned_data = Run_SQL($SQL);

sub Run_SQL {

my $SQL_STMT= shift @_; 

# Set PrintError and RaiseError states to 1 for debugging.
my %attr = ( PrintError = 1, RaiseError = 1 );

# Open a connection to the database or die.
$DBH = DBI-connect(DBI:ODBC:scmdata, user, password, \%attr)
or die Can't connect to DataBase: , $DBI::errstr, \n;

# Prepare the SQL statement and then execute it.
my $sth = $DBH-prepare($SQL_STMT);
$sth-execute();

my @rows;
while( my $array_ref = $sth-fetchrow_arrayref ) {
push @rows, [EMAIL PROTECTED];
}

# Finish and disconnect.
$sth-finish();
$DBH-disconnect();

return @rows;   
}

You'll need to replace the user and password in the code above to 
suit your needs.

Hope this helps.

Carter.


 -Original Message-
 From: Fernando Freire Baez (Medicare)
 [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, February 26, 2003 7:40 AM
 To: '[EMAIL PROTECTED]'
 Subject: [PMX:#] DBI SQL 2000 driver
 
 
 Hello,
 
 I have to make a database in a SQL 2000 server and I will use perl to
 retrieve some data from it. I want to know fi there are 
 driver for DBI to
 connecto to SQL 2000 server. If anybody know about a website 
 that have some
 example code, please let me know. I will apreciate a lot your 
 help. Thanks!
 
 Fernando Freire Baez
 Programador Analista I
 Triple S / Medicare
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: using win32 to mount drives?

2003-02-26 Thread Carter Thompson


H, take a look at Win32::DriveInfo and Win32::NetResource
on CPAN.  I don't know if this will do what you want but it
appears to be related.

Cheers,

Carter.


 -Original Message-
 From: Lance Hoffmeyer [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, February 26, 2003 10:39 AM
 To: [EMAIL PROTECTED]
 Subject: using win32 to mount drives?
 
 
 Hello,
 
 Can someone point me to some info on how I can
 use perl to mount and unmount network drives.
 
 Currently I am using net use with a *.bat file
 to do this.  
 
 I thought it might be easier to write
 a little TKperl GUI that would contain all the 
 mountpoints to mount and unmount instead of filling
 up my desktop with *.bat files.
 
 Lance
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Running a script more than once a day

2003-02-26 Thread Carter Thompson


Actually Andrew, if you like cron and prefer that to Scheduled Tasks and 
AT you could always install cygwin.  http://www.cygwin.com/

With Cygwin you get an editable crontab with the added bonus of having a 
real shell and Unix/Linux utilites.

Cheers,

Carter.

 -Original Message-
 From: Andrew Mansfield [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, February 26, 2003 9:41 AM
 To: [EMAIL PROTECTED]
 Subject: Running a script more than once a day
 
 
 Hopefully this isn't too off topic here, but I'm interested 
 to find out if
 anyone can suggest the best way to run a small perl script at regular
 intervals (e.g. every 15 minutes) during the weekdays on a 
 Windows server
 similar to what you can do with cron on Unix/Linux.
 
 I've found a bunch of shareware type utilities after a quick 
 google, but I
 figured some of you may have already solved this problem..
 
 AT and Scheduled Tasks seem designed for once a day operation..
 
 Thanks,
 
 Andrew Mansfield
 KI
 Green Bay, WI
 
 
 
 
 Feeling out of adjustment?  Try the new KI Task Chair 
 Adjustment Guide at ki.com/taskchairs.  The Task Chair 
 Adjustment Guide features instructions and videos on how to 
 adjust your KI task chairs.  Visit http://www.ki.com/taskchairs
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-Win32-Users]Subject Line

2002-11-22 Thread Carter Thompson


Wow, that's too bad.   I liked the ease of sorting messages with it.
The mailing list is high volume and any help in sorting the Perl
messages from my other 300+ messages a day is always appreciated.

Carter.

 -Original Message-
 From: troy topnik [mailto:[EMAIL PROTECTED]]
 Sent: Friday, November 22, 2002 1:47 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [Perl-Win32-Users]Subject Line 
 
 
  I'll try to hunt down the culprit and punish him or her! :)
 Bring it on Jan! Seriously folks - I saw the request for 
 adding [Perl-Win32-Users] to the subject line and thought it 
 was worth trying, however, Jan is right - this list is too 
 high volume and the name a bit too long to squeeze into the 
 subject line. I've removed the tag from the subject line.
 
 Troy
 
 
  ASPNPRODUCTNAME__PERL ASPNLISTNAME__PERL-WIN32-USERS On 
 Fri, 22 Nov 2002 13:29:26 -0700, Jack 
 [EMAIL PROTECTED] wrote:
  
  It seems that [Perl-Win32-Users] is now a standard string 
 in the subject line. I
  assume this was implemented because of the recent thread 
 discussion?
  
  I like it - but there were others with very good points on 
 why they don't like
  it, so:
  
  Q: Will this continue? i.e. can I change my rules wizard?
  
  I have no idea who turned this on, but I hope it will not continue.
  
  I think it makes a mailing list unreadable, unless you 
 actually read every
  message as it comes in and don't really care about the 
 subject line and
  threading.  It is tolerable on a low volume mailing list, 
 but I think
  totally inappropriate for this one.
  
  I'll try to hunt down the culprit and punish him or her! :)
  
  Cheers,
  -Jan
  
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
   

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: How can I figure out whether it is binary file or ASCII file under one directory?

2002-10-10 Thread Carter Thompson



Why not use the -B operator to test the file for 
binary contents?

if( -B $file) {
# file is binary
} else {
# file is not binary
}

Carter.



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, October 10, 2002 10:54 AM
 To: [EMAIL PROTECTED];
 [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Subject: How can I figure out whether it is binary file or ASCII file
 under one directory?
 
 
 Dear all,
 
 A question, How can I figure out whether it is binary file or 
 ASCII file
 under one directory using perl? Does perl have a function for 
 that? I have a
 project to pick up various binary files from some directories.
 
 Thanks in advance!
 Have a nice day!
 
 Lixin
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: UDP

2002-10-02 Thread Carter Thompson


use IO::Socket to send UDP Packets.  Here's an example
from the Network Programming w/Perl book, page 535.

#!/usr/bin/perl
# file: udp_daytime_cli2.pl

use strict;
use IO::Socket qw(:DEFAULT :crlf);
use constant MAX_MSG_LEN = 100;
$/ = CRLF;
my $data;

my $host = shift || 'localhost';
my $port = shift || 'daytime';

my $sock = IO::Socket::INET-new(Proto  = 'udp',
= $host,
= $port) or die $@;

$sock-send('Yo!') or die send() failed: $!\n;
$sock-recv($data,MAX_MSG_LEN) or die recv() failed: $!\n;

chomp $data;
print $data,\n;

--
Now run it:

% udp_daytime_cli2.pl host.domain.com
Wed Oct 2 17:10:34 2002

Cheers,

Carter.

 -Original Message-
 From: Harald Wopenka [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, October 02, 2002 4:29 PM
 To: [EMAIL PROTECTED]
 Subject: UDP
 
 
  Hi there,
  
  looking for a little example how to send UDP-Pakets via 
 Perl. I found some
 nice things in perldoc, but they didn't work - or I was too dumb to
 implement them.
  
  Thanks in advance
 Harry
  
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: NET::Telnet

2002-09-17 Thread Carter Thompson




The Prompt is a regular expression that matches the
commandline prompt from the remote shell.  That means
you'll want to match the prompt for the user you are
logging in as.  If I log into one of my remote windows
machines through a telnet server and I see I have a 
prompt like so, C:/ I'll need to match that within
my code as prompt.

If the prompt isn't matched in the time specified in 
Timeout then the script will either return false or
die based on what Errmode is set to, return or die
respectively.  

NET::Telnet Defaults:
Timeout = 10
Host = localhost
Errmode = die
Prompt = /[\$%#]$/  # matches most unix shells.
Port = 23

This is how you could establish a connection with a 
windows machine with NET::Telnet (Untested).

use strict;

my $TIMEOUT = 30;
my $PROMPT = C:/; 
my $HOST = foobar.foo.com;
my $USER = Bob;
my $PASS = password;

$telnet = Net::Telnet-new( Timeout = $TIMEOUT,
Prompt  = $PROMPT,
Host= $HOST,
Errmode = return);

$telnet-login($USER, $PASS);

# Test here for success if using return.
my $msg = $telnet-errmsg();
if ($msg) {
print $msg\n;
$telnet-close;
# do whatever you want here.
}



Hope this helps.

Cheers,

Carter.


 -Original Message-
 From: Jitendra Soam [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, September 17, 2002 7:39 AM
 To: [EMAIL PROTECTED]
 Subject: RE: NET::Telnet
 
 
 
 Thanks.
 
 But the what should be used as prompt?
 
 
 
 -Original Message-
 From: Thomas R Wyant_III [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, September 17, 2002 7:01 PM
 To: [EMAIL PROTECTED]
 Subject: Re: NET::Telnet
 
 
 
 Jitendra Soam [EMAIL PROTECTED] wrote:
 
  Is it possible to use Net::Telnet module to telnet into Windows
  machine running Microsoft Telnet Service..
 
 In theory, yes, _provided_ the Telnet service is set up to do
 username/password authentication. This is not the default.
 
 In practice, there appear to be significant problems figuring out what
 you
 should tell it the prompt string is, because Microsoft embeds 
 all sorts
 of
 escape sequences in it.
 
  and start Any program like Notepad on target machine?
 
 In theory, yes. In practice, of course, Notepad displays on the target
 machine's desktop, which probably does you as the owner of the telnet
 link
 no good at all.
 
 Tom Wyant
 
 
 
 This communication is for use by the intended recipient and contains 
 information that may be privileged, confidential or copyrighted under
 applicable law.  If you are not the intended recipient, you are hereby
 formally notified that any use, copying or distribution of 
 this e-mail,
 in whole or in part, is strictly prohibited.  Please notify the sender
 by return e-mail and delete this e-mail from your system.  Unless
 explicitly and conspicuously designated as E-Contract Intended,
 this e-mail does not constitute a contract offer, a contract 
 amendment,
 or an acceptance of a contract offer.  This e-mail does not constitute
 a consent to the use of sender's contact information for direct
 marketing
 purposes or for transfers of data to third parties.
 
  Francais Deutsch Italiano  Espanol  Portuges  Japanese  
 Chinese  Korean
 
 http://www.DuPont.com/corp/email_disclaimer.html
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: NET::Telnet

2002-09-17 Thread Carter Thompson



Before anyone else mentions it - please add the
use NET::Telnet in the example.

I told you it was untested.  ;-)

Carter.

 -Original Message-
 From: Carter Thompson 
 Sent: Tuesday, September 17, 2002 10:22 AM
 To: Jitendra Soam; [EMAIL PROTECTED]
 Subject: RE: NET::Telnet
 
 
 
 
 
 The Prompt is a regular expression that matches the
 commandline prompt from the remote shell.  That means
 you'll want to match the prompt for the user you are
 logging in as.  If I log into one of my remote windows
 machines through a telnet server and I see I have a 
 prompt like so, C:/ I'll need to match that within
 my code as prompt.
 
 If the prompt isn't matched in the time specified in 
 Timeout then the script will either return false or
 die based on what Errmode is set to, return or die
 respectively.  
 
 NET::Telnet Defaults:
 Timeout = 10
 Host = localhost
 Errmode = die
 Prompt = /[\$%#]$/  # matches most unix shells.
 Port = 23
 
 This is how you could establish a connection with a 
 windows machine with NET::Telnet (Untested).
 
 use strict;
 
 my $TIMEOUT = 30;
 my $PROMPT = C:/;   
 my $HOST = foobar.foo.com;
 my $USER = Bob;
 my $PASS = password;
 
 $telnet = Net::Telnet-new( Timeout = $TIMEOUT,
   Prompt  = $PROMPT,
   Host= $HOST,
   Errmode = return);
 
 $telnet-login($USER, $PASS);
 
 # Test here for success if using return.
 my $msg = $telnet-errmsg();
 if ($msg) {
   print $msg\n;
   $telnet-close;
   # do whatever you want here.
 }
 
 
 
 Hope this helps.
 
 Cheers,
 
 Carter.
 
 
  -Original Message-
  From: Jitendra Soam [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, September 17, 2002 7:39 AM
  To: [EMAIL PROTECTED]
  Subject: RE: NET::Telnet
  
  
  
  Thanks.
  
  But the what should be used as prompt?
  
  
  
  -Original Message-
  From: Thomas R Wyant_III [mailto:[EMAIL PROTECTED]] 
  Sent: Tuesday, September 17, 2002 7:01 PM
  To: [EMAIL PROTECTED]
  Subject: Re: NET::Telnet
  
  
  
  Jitendra Soam [EMAIL PROTECTED] wrote:
  
   Is it possible to use Net::Telnet module to telnet into Windows
   machine running Microsoft Telnet Service..
  
  In theory, yes, _provided_ the Telnet service is set up to do
  username/password authentication. This is not the default.
  
  In practice, there appear to be significant problems 
 figuring out what
  you
  should tell it the prompt string is, because Microsoft embeds 
  all sorts
  of
  escape sequences in it.
  
   and start Any program like Notepad on target machine?
  
  In theory, yes. In practice, of course, Notepad displays on 
 the target
  machine's desktop, which probably does you as the owner of 
 the telnet
  link
  no good at all.
  
  Tom Wyant
  
  
  
  This communication is for use by the intended recipient and 
 contains 
  information that may be privileged, confidential or 
 copyrighted under
  applicable law.  If you are not the intended recipient, you 
 are hereby
  formally notified that any use, copying or distribution of 
  this e-mail,
  in whole or in part, is strictly prohibited.  Please notify 
 the sender
  by return e-mail and delete this e-mail from your system.  Unless
  explicitly and conspicuously designated as E-Contract Intended,
  this e-mail does not constitute a contract offer, a contract 
  amendment,
  or an acceptance of a contract offer.  This e-mail does not 
 constitute
  a consent to the use of sender's contact information for direct
  marketing
  purposes or for transfers of data to third parties.
  
   Francais Deutsch Italiano  Espanol  Portuges  Japanese  
  Chinese  Korean
  
  http://www.DuPont.com/corp/email_disclaimer.html
  
  
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Teeing STDERR?

2002-08-21 Thread Carter Thompson



If you just can't get IO::Tee to work, write your own:


This function will print to both STDERR and a specified in
logfile.  The syntax to use it is:

writeit(Your String\n, $YOUR_LOGFILE);

Here's the function:

sub writeit{

my $string = shift @_;
my $LOG = shift @_;

open (LOGFILE,  $LOG) || die can't open $LOG: $!;
LOGFILE-autoflush(1);
STDERR -autoflush(1);

@log_array = ( LOGFILE, STDERR );

foreach $logfile (@log_array) {
print $logfile $string
}

close(LOGFILE) || die can't close $LOG: $!;

}


I think this could be cleaned up a wee bit but it works.

Cheers,

Carter.



 -Original Message-
 From: Martin Moss [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, August 21, 2002 7:58 AM
 To: [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Subject: Re: Teeing STDERR?
 
 
 I use a set of Modules I wrote to do something simillar.
 Bficient::Logger.
 
 It simply ties, STDERR ( optionally STDOUT) to a log file, 
 and reformats
 each output with a time, date, PID and ProcessName. Whilst 
 this doesn't
 duplicate output, I'm sure it could do with a few simple 
 additions, to the
 backend module.
 
 the basic principle is:-
 save STDERR
 close STDERR
 
 open STDERR,  $logfile
 use a sub module to catch different types of output. (print etc..)
 
 To make it print to multiple files would be as simple as not 
 closing the
 original STDERR, printing the message to the original STDERR 
 as well as the
 new logfile STDERR.
 
 If you would like I could post a copy of the module,
 
 Regards
 
 Marty
 
 
 
 - Original Message -
 From: Philip Morley [EMAIL PROTECTED]
 To: [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Wednesday, August 21, 2002 2:11 PM
 Subject: RE: Teeing STDERR?
 
 
 
  It's only 3 pages long, I've seen far worse Perl documentation ;-)
 
  Here's a simple example of teeing STDERR using IO::Tee:
 
  use strict;
  use IO::Tee;
 
  open(ERRFILE, C:/errors.txt)  || die Error opening file: $!\n;
  my $tee = IO::Tee-new(\*STDERR, \*ERRFILE);
 
  print $tee This is an error that will print to STDERR and 
 errors.txt\n;
 
  close ERRFILE;
 
  HTH,
 
  Phil Morley
 
 
 
  |-+---
  | |   Beckett Richard-qswi266 |
  | |   [EMAIL PROTECTED]  |
  | |   Sent by:|
  | |   [EMAIL PROTECTED]|
  | |   veState.com |
  | |   |
  | |   |
  | |   21/08/02 13:08  |
  | |   |
  |-+---
 
 -
 --
 -|
|
 |
|To:  [EMAIL PROTECTED]
 |
|cc:
 |
|Subject: RE: Teeing STDERR?
 |
 
 -
 --
 -|
 
 
 
  I looked it up, but don't understand it's documentation. Is there an
 easier
  to use module, or can anyone tell me how to do it with IO::Tee?
 
  Thanks.
 
  R.
 
   There is a module called IO::Tee, which should do what 
 you are asking.
  
   Regards,
  
   Phil Morley
 
 
   Hi folks,
  
   I want to have STDERR output to the screen in the normal way,
   but I also
   want it logged to a file, which can be overwritten each time
   the program
   runs. I tried:
  
   open (STDERR, | tee  err.txt) or die can't redirect 
 STDERR: $!\n;
  
   which should work under unix, but as I'm using active state
   perl under W2K,
   I get the following error:
  
   'tee' is not recognised as an internal or external 
 command, operable
   program
   or batch file.
  
   What's the best way to do this?
  
   Thanks.
  
   R.
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 
 
 
 
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: From dos to a window.

2002-08-20 Thread Carter Thompson



I prefer Perl/Tk for windows type of applications and
a pretty nice book exists for it, Mastering Perl/Tk
from O'Reilly.  However, Win32::GUI and Win32::API are 
avaliable if you're unconcerned with multiplatform 
support of your application.

Cheers,

Carter.


 -Original Message-
 From: Beckett Richard-qswi266 [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, August 20, 2002 6:36 AM
 To: [EMAIL PROTECTED]
 Subject: From dos to a window.
 
 
 Chaps,
 
 I've just got my first proper script running nicely, but 
 it's text based
 and runs in a dos window.
 
 I assume that there are modules that allow you to make it look cool by
 running in it's own window, with boxes for data entry, etc.
 
 Can anyone point me to a good module for a beginner, that has good
 documentation to go with it?
 
 Thanks.
 
 R.
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regexp

2002-08-14 Thread Carter Thompson



Interesting, seems to work fine.  Verify the 
contents of $was and $is and then try this:

($newstring = $_) =~ s/$was/$is/;

print (Newstring is: $newstring\n);

Cheers,

Carter.



 -Original Message-
 From: Jacobson, Karl [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, August 14, 2002 3:46 PM
 To: [EMAIL PROTECTED]
 Subject: regexp
 
 
 I am trying simply to do a search and replace and have 
 identified the string
 that I want to replace with another.
 
 $_ holds the string to be manipulated
 $was holds the search string (split from an input file)
 $is holds the replacement string (also split from an input file)
 
 s/$was/$is/; doesn't work and I expected that it would.  What 
 is missing?
 
 Karl
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: :Telnet under windows - vxworks

2002-08-09 Thread Carter Thompson




Lawrence,

What happens when you do:

@lines = $telnet - cmd(ls);

An example of your code would be useful in determining 
what
your problem is.

Cheers,

Carter.


  -Original Message-From: Lawrence Lordanich (x11486) 
  [mailto:[EMAIL PROTECTED]]Sent: Friday, August 09, 2002 9:33 
  AMTo: perl win32 usersSubject: Net::Telnet under windows 
  - vxworksI have installed Net-Telnet on my pc and am 
  trying to telnet to a vxworks platform. Would anybody be able to enlighten me 
  about how to get good stuff back from a $obj-cmd() call? I am trying 
  setting binmode, changing the input separator etc ... but have yet to get good 
  stuff back from a simple ls command. I can telnet from a cmd.exe window ok. 
  Does not seem to be a perms/admin 
  problem.Thanks,Lawrence.
  Lawrence 
  Lordanich 
  Tel: +1 858-651-1486Qualcomm Inc. 
  (E-140F) 
  Fax: +1 858-845-82224875 Eastgate 
  Mall 
  Email: [EMAIL PROTECTED]San Diego, CA 92121-1978 
  TimeZone: GMT-8 (PST)