click on image in win32::IeAutomation

2012-07-31 Thread Perl Pra
I am using Win32::IE Automation to automate login of a page.

I could provide username and password in the respectivve fields,But the
login is a image on which I need to click. Below is the page source for
that login image .

 

So to click on the image I am doing the following.


I used $ie->getImage('imgurl:', qr/img_1.jpg/)->Click();
It says "Can't call method "Click" on an undefined value"
When I try to get all the images on the page Using

my @array=$ie->getAllImages();
print Dumper (@images)

It sas "Out OF memory".
How can I Click on the above mentioned image.

Any Inputs appreciated

Thanks
Pra


problem install XML::LibXSLT on RHEL

2012-06-03 Thread Perl Pra
Hi Gurus,

I have written a program that uses XML::LibXSLT. When i Run the program it
complain about not findind the XML/LibXSLT  @INC.


I have installed perl-libxml and perl-lib-xslt successfully .Still my perl
progam complains about XML::LibXSLT not installed.

1) * when I run Perl MakeFile.PL to install XML::LibXSLT ( I get the below
error)*
**
running xslt-config... failed
XML::LibXSLT needs libxslt version 1.1.18 or higher
**
**
*2) Now I am trying to install libxslt when I run ./configure*
It gives me the following error even though i have 2.6.28 lib avaiable on
/usr/local/lib.
checking for libxml libraries >= 2.6.27... configure: error: Version 2.6.26
found. You need at least libxml2 2.6.27 for this version of libxslt

*3) But I have install libxml2 2.6.28 and it resides ins /usr/loca/lib (see
below)*

-rwxr-xr-x 1 root root 4162762 May 29 10:59 libxml2.so.2.7.8
-rwxr-xr-x 1 root root 4076119 Jun  4 00:06 libxml2.so.2.6.28
lrwxrwxrwx 1 root root  17 Jun  4 00:06 libxml2.so -> libxml2.so.2.6.28
-rwxr-xr-x 1 root root 807 Jun  4 00:06 libxml2.la
lrwxrwxrwx 1 root root  16 Jun  4 00:06 libxml2.so.2 -> libxml2.so.2.7.8
-rw-r--r-- 1 root root 6441062 Jun  4 00:06 libxml2.a
-rw-r--r-- 1 root root 211 Jun  4 00:06 xml2Conf.sh
drwxr-xr-x 2 root root4096 Jun  4 00:06 pkgconfig

can somebody help me in resolving this issue? I did ldconfig too but no use.

Thnaks,
c


perl DBI problem while installing bugzilla

2010-08-11 Thread perl pra
> Hi All,
>
>  I am having a problem while isntalling Bugzilla , Checksetup.pl throws
> errors and exits.Below is the detail.
>
> when I run checksetup.pl in bugzilla folder I get the following error,
> Though  I have installed latest DBD-mysql which is available in CPAN.
>
> ERROR ---
>
> Checking formod_perl (v1.999022) ok: found v2.03
> Reading ./localconfig...
> Checking for   DBD-mysql (v4.00)   ok: found v4.016
>
> *Undefined subroutine &DBD::mysql::db::_login called at
> /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/mysql.pm line
> 142,  line 522.*
>
>
> ERROR ---
>
> Can any help me in solving this I am stuck up here.
>
> thanks,
> Siva
>


problem while installing bugzilla

2010-08-11 Thread perl pra
Hi All,

 I am having a problem while isntalling Bugzilla , Checksetup.pl throws
errors and exits.Below is the detail.

when I run checksetup.pl in bugzilla folder I get the following error,
Though  I have installed latest DBD-mysql which is available in CPAN.

ERROR ---

Checking formod_perl (v1.999022) ok: found v2.03
Reading ./localconfig...
Checking for   DBD-mysql (v4.00)   ok: found v4.016

*Undefined subroutine &DBD::mysql::db::_login called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/mysql.pm line
142,  line 522.*


ERROR ---

Can any help me in solving this I am stuck up here.

thanks,
Siva


Detaching the .eml attachment

2010-01-25 Thread perl pra
Hi All,

I have a .eml file which has either PDF/xls attachment,

I want to strip this attachment from .eml and store in the local hard drive.

I have tried it with the Email::Attachment::Stripper with no luck.

please help me in this.

Thanks,
siva


Re: could not execute psexec

2009-12-07 Thread perl pra
Hi All,

I have done the following.

printed the cmd variable and check what actually got passed. If I copy paste
the printed command on dos prompt it worked fine.

I think its not intallation issues as I could execute the command from the
dos prompt.

Thanks,
siva

On Tue, Dec 8, 2009 at 1:02 AM, Bob goolsby  wrote:

> Funniest thing -- when I run psexc from the command line I get:
>
>
> C:\Documents and Settings>psexec
> 'psexec' is not recognized as an internal or external command,
> operable program or batch file.
>
> C:\Documents and Settings>psexec.exe
> 'psexec.exe' is not recognized as an internal or external command,
> operable program or batch file.
>
> C:\Documents and Settings>
>
>
> Rather odd, you think?
>
> Further investigation yields the fact the PsExec is a "PsExec is a
> light-weight telnet-replacement that lets you execute ... Just copy
> PsExec onto your executable path. Typing "PsExec" displays its
> usage" (From the fine on-line documentation.)
>
> Sounds like you have an installation issue 
>
>
> B
>
>
>
>
> On Mon, Dec 7, 2009 at 5:51 AM, C.DeRykus  wrote:
> > On Dec 7, 4:29 am, perl...@gmail.com (Perl Pra) wrote:
> >> Hi All,
> >>
> >> I need to execute "*psexec.exe"* which is in C:\Windows\system32 through
> >> perl scirpt.
> >> .I am getting  the error "*'psexec' is not recognized as an internal or
> >> external command,operable program or batch file"*
> >>
> >> Below is the perl script.
> >>
> >> --- SNIP
> >> #!/usr/bin/perl -w
> >> use strict;
> >> use warnings;
> >> use File::Copy;
> >> use File::Find;
> >>
> >>  $ENV{path}= $ENV{path} . ';' .  'C:\\Windows\\System32';
> >> my  $cmd='psexec' . " " . '' . 10.1.1.121 . ' -u ' .  "Adminuser"  .
> '
> >> -p ' . "adminpassword" . ' -w ' .  "C:\\commands\\AutoIT\\ ".  "
> >> \"C:\\commands\\AutoIT\\sch.bat\"";
> >> system("$cmd") or die "$!";
> >
> >
> > Did you already try printing out $cmd before calling 'system" to
> > see what actually gets passed ...?
> >
> > Also, in case of error, the error value will be found in  $?
> > normally.
> > Only if the return is -1 can $! be inspected for the error.  See
> > perldoc -f system.
> >
> > And your expression reports an error only if the system return
> > is zero.  That's backwards  since a successful call exits with 0.
> > At least normally...
> >
> > Here's what the doc (perldoc -f system) recommends:
> >
> > system ($cmd );
> > if ($? == -1) {
> >  print "failed to execute: $!\n";
> > }
> > elsif ($? & 127) {
> >printf "child died with signal %d, %s coredump\n",
> >($? & 127),  ($? & 128) ? 'with' : 'without';
> > }
> > else {
> >printf "child exited with value %d\n", $? >> 8;
> > }
> >
> >> PS: If i directly run the command on dos promt it gets executed, I am
> >> getting error if I run the command through perl script only.
> >> Please help me with the below.
> >>
> >
> > --
> > Charles DeRykus
> >
> >
> > --
> > To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> > For additional commands, e-mail: beginners-h...@perl.org
> > http://learn.perl.org/
> >
> >
> >
>


could not execute psexec

2009-12-07 Thread perl pra
Hi All,

I need to execute "*psexec.exe"* which is in C:\Windows\system32 through
perl scirpt.
.I am getting  the error "*'psexec' is not recognized as an internal or
external command,operable program or batch file"*

Below is the perl script.

--- SNIP
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Copy;
use File::Find;

 $ENV{path}= $ENV{path} . ';' .  'C:\\Windows\\System32';
my  $cmd='psexec' . " " . '' . 10.1.1.121 . ' -u ' .  "Adminuser"  . '
-p ' . "adminpassword" . ' -w ' .  "C:\\commands\\AutoIT\\ ".  "
\"C:\\commands\\AutoIT\\sch.bat\"";
system("$cmd") or die "$!";
--SNIP.


PS: If i directly run the command on dos promt it gets executed, I am
getting error if I run the command through perl script only.
Please help me with the below.

Thanks,
Siva


.eml parsing and downlaod

2009-09-08 Thread perl pra
Hi Gurus,

Can anybody let me know how can I download attachment of a .eml file using
perl script to a specified location.

Thanks in Adavance
PP


installing perl modules on 64-bit Os

2009-08-15 Thread perl pra
Hi Gurus,

I have installed  "ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi" on
WindowsServer 2008 64-bit OS. I can run the scripts that I have written on
32-bit OS,My query is whats the processes of installing perl modules on
64-bit OS. In 32-bit we use nmake to install, how to install modules on
64-bit.

Thanks in Advance,
PP


Accessing . NET Webserivices

2009-08-14 Thread perl pra
Hi all,

I have a webserives built in .NET and WSE authentication which i wanted
to consume  through perlclient.Below are the details.

I have a windows webservice, Now i wanted to test these services, I wanted
to consume them with perl client, These webservices are WSSE authenticated.I
have tried with SOAP::Lite to generate the xml file with no luck,Can anybody
help me or give me a sample script that generates the following xml file and
fire it.

Thanks in Advance,
Siva

Snippet

---

  http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="
http://www.w3.org/2001/XMLSchema"; xmlns:wsa="
http://schemas.xmlsoap.org/ws/2004/08/addressing"; xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
">

  http://Company.product.Service.ServiceContracts/2001/30
">
SessId=5af2c681-dc3b-4fe3-83cf-1aabb516a110
  
  
http://Company.product.Service.ServiceContracts/2001/30/GetMethod


urn:uuid:f5df3b71-7ef4-4b07-acaf-532aaa282332
  

http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous

  
  
http://ProductServer/ProductService/Service.asmx

  

  2009-07-29T15:56:09Z
  2009-07-29T16:01:09Z

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
wsu:Id="SecurityToken-9875f42d-6a7e-4ded-b3fd-108a1f9a8496">

D1672EB1-8C45-4a8c-BBC7-E2F3C599494C
  http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest";>5XqKxPGhN0z44I9kvW6mB6mc28A=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest%22%3E5XqKxPGhN0z44I9kvW6mB6mc28A=%3C/wsse:Password>
>
  umOrMTyRd/BY3o4CaBwgZA==
  2009-07-29T15:56:09Z

  


  http://Company.product.Service.ServiceContracts/2001/30"
/>

  
--


Re: Accessing windows webservices

2009-08-05 Thread perl pra
>
> Hi all,
>
> I have a windows webService which i wanted to consume  through
> perlclient.Below are the details.
>
> I have a windows webservice, Now i wanted to test these services, I wanted
> to consume them with perl client, These webservices are WSSE authenticated.I
> have tried with SOAP::Lite to generate the xml file with no luck,Can anybody
> help me or give me a sample script that generates the following xml file and
> fire it.
>
> Thanks in Advance,
> Siva
>
> Snippet
>
>
> ---
>
>   http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="
> http://www.w3.org/2001/XMLSchema"; xmlns:wsa="
> http://schemas.xmlsoap.org/ws/2004/08/addressing"; xmlns:wsse="
> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
> xmlns:wsu="
> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
> ">
> 
>   http://Company.product.Service.ServiceContracts/2001/30
> ">
> SessId=5af2c681-dc3b-4fe3-83cf-1aabb516a110
>   
>   
> http://Company.product.Service.ServiceContracts/2001/30/GetMethod
> 
>
> urn:uuid:f5df3b71-7ef4-4b07-acaf-532aaa282332
>   
> 
> http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
> 
>   
>   
> http://ProductServer/ProductService/Service.asmx
> 
>   
>  wsu:Id="Timestamp-c87828a4-9a3b-42e5-b5d8-a92ce425aeee">
>   2009-07-29T15:56:09Z
>   2009-07-29T16:01:09Z
> 
> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
> wsu:Id="SecurityToken-9875f42d-6a7e-4ded-b3fd-108a1f9a8496">
>
> D1672EB1-8C45-4a8c-BBC7-E2F3C599494C
>   http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest";>5XqKxPGhN0z44I9kvW6mB6mc28A=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest%22%3E5XqKxPGhN0z44I9kvW6mB6mc28A=%3C/wsse:Password>
> >
>   umOrMTyRd/BY3o4CaBwgZA==
>   2009-07-29T15:56:09Z
> 
>   
> 
> 
>   http://Company.product.Service.ServiceContracts/2001/30"
> />
> 
>   
>
> --
>


Accessing windows webservices

2009-07-30 Thread perl pra
Hi all,

I have a windows webService which i wanted to consume  through
perlclient.Below are the details.

I have a windows webservice, Now i wanted to test these services, I wanted
to consume them with perl client, These webservices are WSSE authenticated.I
have tried with SOAP::Lite to generate the xml file with no luck,Can anybody
help me or give me a sample script that generates the following xml file and
fire it.

Thanks in Advance,
Siva

Snippet

---

  http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="
http://www.w3.org/2001/XMLSchema"; xmlns:wsa="
http://schemas.xmlsoap.org/ws/2004/08/addressing"; xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
">

  http://Company.product.Service.ServiceContracts/2001/30
">
SessId=5af2c681-dc3b-4fe3-83cf-1aabb516a110
  
  
http://Company.product.Service.ServiceContracts/2001/30/GetMethod


urn:uuid:f5df3b71-7ef4-4b07-acaf-532aaa282332
  

http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous

  
  http://ProductServer/ProductService/Service.asmx
  

  2009-07-29T15:56:09Z
  2009-07-29T16:01:09Z

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
wsu:Id="SecurityToken-9875f42d-6a7e-4ded-b3fd-108a1f9a8496">

D1672EB1-8C45-4a8c-BBC7-E2F3C599494C
  http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest";>5XqKxPGhN0z44I9kvW6mB6mc28A=
  umOrMTyRd/BY3o4CaBwgZA==
  2009-07-29T15:56:09Z

  


  http://Company.product.Service.ServiceContracts/2001/30"
/>

  
--


Re: file handle in perl

2009-06-18 Thread perl pra
you can also Tie::File.

On Wed, Jun 17, 2009 at 2:42 PM, Irfan Sayed wrote:

> Hi All,
>
> I am struggling with file handling in perl. i want to do following
> operation .
>
> 1: open the file
> 2: read the file
> 3: do the changes in specific lines
> 4: save the file
> 5: close the file
>
> i am not getting which operand i should use to do this operation . i tried
> all operands like >, >>, <, +<, +>
>
> please advice
>
> here is the line which i am using to open the file
>
> open (FILE, "+<", '.\Metrino\MonitoringSystem\Rtu\RtuInstallKit\EXFO RTU
> System\EXFO RTU System.vdproj') or die "Couldn't open for reading: $!\n";
>
> plz plz advic
>
> regards
> Irf
>
>
>
>


dragandrop with win32::IE automation.

2009-04-19 Thread perl pra
Hi gurus,

Can I drag and drop a text using win32::IE Automation.here is my
requirement.I have a text in a table i have to drag and drop that text into
another area of webpage.

Can i do that using Win32::IEAutomation?


Thanks in Advance,
PP


Re: perl script errors while connecting to sql server

2009-04-19 Thread perl pra
Hi

I am able to connect to my remote sql server through SQL express Managment
console.

I have configured my sqlserver to allow remote connections.

Thanks,
siva


On 4/16/09, Jayesh Thakrar  wrote:
>
>
> From what I understand, the Express Edition of MS SQL Server does not
> support connections from remote machines/hosts out-of-the-box.
>
> Look up the Microsoft KB article and turn-on support for remote connections
> and then try.
>
> http://support.microsoft.com/kb/914277
>
> -- Jayesh
>
>
>
>
> - Original Message 
> From: perl pra 
> To: Beginners List 
> Sent: Thursday, April 16, 2009 4:27:14 AM
> Subject: perl script errors while connecting to sql server
>
> Hi Gurus,
>
> I need to connect to MSSQL SERVER (express edition on remote system)
> through
> a perl script. But I get the following error with the code below can any
> body help me in that.
>
>  ERROR
>
> Use of uninitialized value $Win32::ODBC::ErrConn in concatenation (.) or
> string
> at C:/Perl/lib/Win32/ODBC.pm line 785.
> Unable to connect to DSN Databasesysadm:[17] [] "[Microsoft][ODBC SQL
> Server
> Dri
> ver][TCP/IP Sockets]SQL Server does not exist or access denied."
>
>  ERROR
>
> ## CODE SNIP
>
> my $user="sqlserver";
> my $pw="servertest";
> my $dsn="Databasesysadm"; # name of the DSN we will be using
> my $SERVER="remotemachine";
> my $DB="projDB";
> my %dsnavail;
> my @cols;
> my @dbs;
> my $table;
> my @tables;
>
>
>
> die "Unable to query available DSN's".Win32::ODBC::Error(  )."\n"   unless
> (%dsnavail = Win32::ODBC::DataSources(  ));
>
> foreach my $key (keys %dsnavail)
> {
> print "$key=$dsnavail{$key}\n";
> }
>
> if (!defined $dsnavail{$dsn})
> {
>die "unable to create DSN:".Win32::ODBC::Error(  )."\n"
>  unless (Win32::ODBC::ConfigDSN(ODBC_ADD_DSN,  "SQL Server",
> ("DSN=$dsn",  "DESCRIPTION=DSN for PerlSysAdm",  "SERVER=remotemachine",
> "DATABASE=$DB", "NETWORK=DBMSSOCN",)));
> }
>
>
> my $dbh = new Win32::ODBC("DSN=$dsn;UID=$user;PWD=$pw;");
>
> die "Unable to connect to DSN $dsn:".Win32::ODBC::Error(  )."\n"  unless
> (defined $dbh);
>
> # find the databases on the server
> if (defined $dbh->Sql(q{SELECT name from sysdatabases}))
> {
>die "Unable to query databases:".Win32::ODBC::Error(  )."\n";
> }
>
>
> $dbh->Close(  );
>
> die "Unable to delete DSN:".Win32::ODBC::Error(  )."\n"unless
> (Win32::ODBC::ConfigDSN(ODBC_ REMOVE_DSN, "SQL Server","DSN=$dsn"));
>
> ## CODE SNIP
>
> Thanks,
>
> PP
>
>
>
>
>
>


perl script errors while connecting to sql server

2009-04-16 Thread perl pra
Hi Gurus,

I need to connect to MSSQL SERVER (express edition on remote system) through
a perl script. But I get the following error with the code below can any
body help me in that.

 ERROR

Use of uninitialized value $Win32::ODBC::ErrConn in concatenation (.) or
string
at C:/Perl/lib/Win32/ODBC.pm line 785.
Unable to connect to DSN Databasesysadm:[17] [] "[Microsoft][ODBC SQL Server
Dri
ver][TCP/IP Sockets]SQL Server does not exist or access denied."

 ERROR

## CODE SNIP

my $user="sqlserver";
my $pw="servertest";
my $dsn="Databasesysadm"; # name of the DSN we will be using
my $SERVER="remotemachine";
my $DB="projDB";
my %dsnavail;
my @cols;
my @dbs;
my $table;
my @tables;



die "Unable to query available DSN's".Win32::ODBC::Error(  )."\n"   unless
(%dsnavail = Win32::ODBC::DataSources(  ));

foreach my $key (keys %dsnavail)
{
 print "$key=$dsnavail{$key}\n";
}

if (!defined $dsnavail{$dsn})
{
die "unable to create DSN:".Win32::ODBC::Error(  )."\n"
  unless (Win32::ODBC::ConfigDSN(ODBC_ADD_DSN,  "SQL Server",
("DSN=$dsn",  "DESCRIPTION=DSN for PerlSysAdm",  "SERVER=remotemachine",
"DATABASE=$DB", "NETWORK=DBMSSOCN",)));
}


my $dbh = new Win32::ODBC("DSN=$dsn;UID=$user;PWD=$pw;");

die "Unable to connect to DSN $dsn:".Win32::ODBC::Error(  )."\n"  unless
(defined $dbh);

# find the databases on the server
if (defined $dbh->Sql(q{SELECT name from sysdatabases}))
{
die "Unable to query databases:".Win32::ODBC::Error(  )."\n";
}


$dbh->Close(  );

die "Unable to delete DSN:".Win32::ODBC::Error(  )."\n"unless
(Win32::ODBC::ConfigDSN(ODBC_ REMOVE_DSN, "SQL Server","DSN=$dsn"));

 ## CODE SNIP

 Thanks,

PP


could not connect to Mssqlserver

2009-04-14 Thread perl pra
Hi Gurus,

I need to connect to MSSQL SERVER (express edition on remote system) through
a perl script. But I get the following error with the code below can any
body help me in that.

 ERROR

Use of uninitialized value $Win32::ODBC::ErrConn in concatenation (.) or
string
at C:/Perl/lib/Win32/ODBC.pm line 785.
Unable to connect to DSN Databasesysadm:[17] [] "[Microsoft][ODBC SQL Server
Dri
ver][TCP/IP Sockets]SQL Server does not exist or access denied."

 ERROR

## CODE SNIP

my $user="sqlserver";
my $pw="servertest";
my $dsn="Databasesysadm"; # name of the DSN we will be using
my $SERVER="remotemachine";
my $DB="projDB";
my %dsnavail;
my @cols;
my @dbs;
my $table;
my @tables;



die "Unable to query available DSN's".Win32::ODBC::Error(  )."\n"   unless
(%dsnavail = Win32::ODBC::DataSources(  ));

foreach my $key (keys %dsnavail)
{
 print "$key=$dsnavail{$key}\n";
}

if (!defined $dsnavail{$dsn})
{
die "unable to create DSN:".Win32::ODBC::Error(  )."\n"
  unless (Win32::ODBC::ConfigDSN(ODBC_ADD_DSN,  "SQL Server",
("DSN=$dsn",  "DESCRIPTION=DSN for PerlSysAdm",  "SERVER=remotemachine",
"DATABASE=$DB", "NETWORK=DBMSSOCN",)));
}


my $dbh = new Win32::ODBC("DSN=$dsn;UID=$user;PWD=$pw;");

die "Unable to connect to DSN $dsn:".Win32::ODBC::Error(  )."\n"  unless
(defined $dbh);

# find the databases on the server
if (defined $dbh->Sql(q{SELECT name from sysdatabases}))
{
die "Unable to query databases:".Win32::ODBC::Error(  )."\n";
}


$dbh->Close(  );

die "Unable to delete DSN:".Win32::ODBC::Error(  )."\n"unless
(Win32::ODBC::ConfigDSN(ODBC_REMOVE_DSN, "SQL Server","DSN=$dsn"));

 ## CODE SNIP





Thanks,

Siva


MSI Installer Automation

2009-04-10 Thread perl pra
Hi All,

Can anybody help me in MSI Installer Automation. How can i do  that in perl.

Is there any module which does that .

Thanks in Advance,
Siva


Re: accessing remote registry

2009-02-09 Thread perl pra
Hi Jenda,

I get the same error even if i remvoe the backslashes.

Thanks,
siva


On 2/6/09, Jenda Krynicky  wrote:
>
> From: perl pra 
> > Can anybody help in accessing the registry of remote windows machine and
> get
> > the keys in the folder  *HKEY_LOCAL_MACHINE/SOFTWARE *
> > **
> > I have tried using win32::Registry, but i am getting the error "cannot
> open
> > the registry",But the same script works if i assign $node  to my local
> Ip.
> >
> > Can somebody help me with the below script, so that this works for remote
> > IPs also.
> >
> > please check the code below:
> >
> >
> > --
> >
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
> >
> > use Win32::Registry;
> > my ($node) = 'your_ip_here';
> > my $Register='SOFTWARE';
> > my ($hNode, $hKey, @key_list);
> >
> > $HKEY_LOCAL_MACHINE->Connect ($node, $hNode) or  die "Cannot connect to
> > $node";
>
> I do not think there should be the backslashes there.
>
> Jenda
> = je...@krynicky.cz === http://Jenda.Krynicky.cz =
> When it comes to wine, women and song, wizards are allowed
> to get drunk and croon as much as they like.
>-- Terry Pratchett in Sourcery
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


accessing remote registry

2009-02-06 Thread perl pra
Hi All,

Can anybody help in accessing the registry of remote windows machine and get
the keys in the folder  *HKEY_LOCAL_MACHINE/SOFTWARE *
**
I have tried using win32::Registry, but i am getting the error "cannot open
the registry",But the same script works if i assign $node  to my local Ip.

Can somebody help me with the below script, so that this works for remote
IPs also.

please check the code below:


--

#!/usr/bin/perl
use strict;
use warnings;

use Win32::Registry;
my ($node) = 'your_ip_here';
my $Register='SOFTWARE';
my ($hNode, $hKey, @key_list);

$HKEY_LOCAL_MACHINE->Connect ($node, $hNode) or  die "Cannot connect to
$node";
$hNode->Open ("$Register", $hKey) or  die "Cannot open registry !";
$hKey->GetKeys(\...@key_list);
print "@key_list\n";
$hKey->Close ();

$hNode->Close ();
---


**


running perl script on remote windows machine

2009-02-06 Thread perl pra
Hi

I have a pel script  I want to execute this perl script on remote machine
and get the information related to remote machine.(both local and remote
machines are Windows machines)

Hwo can i do that


thanks,
PP


Fwd: Thread managment in Perl

2008-12-31 Thread perl pra
 Hi All,

I dont see error if i run the same script on Linux.
But it still firing 100 requests in 6 seconds insted of 1 second.

Any pointers on this?

Thanks,
PP


 On 12/30/08, zentara  wrote:
>
> On Tue, 30 Dec 2008 14:47:08 +0530, perl...@gmail.com ("perl pra")
> wrote:
>
> >Hi All,
> >
> >I am trying out a jmeter like tool with perl.The following are the tasks
> >that my perl script needs to do.
> >
> >1) Fire  specified number of http requests in one second.
> >2) log the response times of the request.
> >3) the Thread should be freed once it completes the task.
> >
> >The following are the issues i am facing.
> >
> >1) I am getting the following errors
> >
> >*Free to wrong pool xxx not yyy at
> >C:/Perl/lib/**constant.pm*<http://constant.pm/>
> >* line -1."  and Free to wrong pool xxx not yyy at
> >C:/Perl/lib/XSLoader.pm  line -1."  *randomly.
> >2) I have  said the perl script to fire 100 simaltaneous request in one
> >second ,but it is firing 100 requests in 6 seconds.
> >
> >3) help me in freeing the thread as soon as it completes the task.
> >
> >
> >*my environment* :
> >
> >*OS:* WinXp ,(SP2)
> >*PERL: *perl  v5.8.8 built for MSWin32-x86-multi-thread,Binary build 822
> >[280952] provided by ActiveState 
> >http://www.ActiveState.com<http://www.activestate.com/>
> >
> >
> >Please go through the following code and help me in resolving the issues:
>
> Hi,
>
> I ran your code "as is", and experienced no problem on Linux. Of course
> all the entries were marked 'FAIL'.
>
> I changed your domain to 'http://google.com' and the same thing. Of
> course, you are posting not getting in your LWP code.
>
> The threads works fine and there was no "free to wrong pool" errors.
>
> So I suspect a Window's problem. Have you tried running this on a
> linux box?  You might want to upgrade to the latest perl 5.10 and see
> if it's fixed.  I suggest CamelBox http://code.google.com/p/camelbox/
>
> You might want to ask this at http://perlmonks.org where there are
> more people who run windows and can test it.
>
> Goodluck,
> zentara
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: Thread managment in Perl

2008-12-31 Thread perl pra
Hi All,

I dont see error if i run the same script on Linux.
But it still firing 100 requests in 6 seconds insted of 1 second.

Any pointers on this?

Thanks,
PP


On 12/30/08, zentara  wrote:
>
> On Tue, 30 Dec 2008 14:47:08 +0530, perl...@gmail.com ("perl pra")
> wrote:
>
> >Hi All,
> >
> >I am trying out a jmeter like tool with perl.The following are the tasks
> >that my perl script needs to do.
> >
> >1) Fire  specified number of http requests in one second.
> >2) log the response times of the request.
> >3) the Thread should be freed once it completes the task.
> >
> >The following are the issues i am facing.
> >
> >1) I am getting the following errors
> >
> >*Free to wrong pool xxx not yyy at
> >C:/Perl/lib/**constant.pm*<http://constant.pm/>
> >* line -1."  and Free to wrong pool xxx not yyy at
> >C:/Perl/lib/XSLoader.pm  line -1."  *randomly.
> >2) I have  said the perl script to fire 100 simaltaneous request in one
> >second ,but it is firing 100 requests in 6 seconds.
> >
> >3) help me in freeing the thread as soon as it completes the task.
> >
> >
> >*my environment* :
> >
> >*OS:* WinXp ,(SP2)
> >*PERL: *perl  v5.8.8 built for MSWin32-x86-multi-thread,Binary build 822
> >[280952] provided by ActiveState http://www.ActiveState.com
> >
> >
> >Please go through the following code and help me in resolving the issues:
>
> Hi,
>
> I ran your code "as is", and experienced no problem on Linux. Of course
> all the entries were marked 'FAIL'.
>
> I changed your domain to 'http://google.com' and the same thing. Of
> course, you are posting not getting in your LWP code.
>
> The threads works fine and there was no "free to wrong pool" errors.
>
> So I suspect a Window's problem. Have you tried running this on a
> linux box?  You might want to upgrade to the latest perl 5.10 and see
> if it's fixed.  I suggest CamelBox http://code.google.com/p/camelbox/
>
> You might want to ask this at http://perlmonks.org where there are
> more people who run windows and can test it.
>
> Goodluck,
> zentara
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: Thread managment in Perl

2008-12-30 Thread perl pra
Hi All,

I am trying out a jmeter like tool with perl.The following are the tasks
that my perl script needs to do.

1) Fire  specified number of http requests in one second.
2) log the response times of the request.
3) the Thread should be freed once it completes the task.

The following are the issues i am facing.

1) I am getting the following errors

*Free to wrong pool xxx not yyy at
C:/Perl/lib/**constant.pm*
* line -1."  and Free to wrong pool xxx not yyy at
C:/Perl/lib/XSLoader.pm  line -1."  *randomly.
2) I have  said the perl script to fire 100 simaltaneous request in one
second ,but it is firing 100 requests in 6 seconds.

3) help me in freeing the thread as soon as it completes the task.


*my environment* :

*OS:* WinXp ,(SP2)
*PERL: *perl  v5.8.8 built for MSWin32-x86-multi-thread,Binary build 822
[280952] provided by ActiveState http://www.ActiveState.com


Please go through the following code and help me in resolving the issues:



### SNIP


use 5.8.8;
use strict;
use warnings;
use LWP;
use LWP::Simple;
use threads;
use Time::HiRes qw/gettimeofday/;


sub HTTP_Req
{

 my($tid,$host,$port,$uri)=...@_;
 open my $FH, '>>', "test.csv" or die "$!";
 my $req = new HTTP::Request 'POST';
 my $url='http:' . '//' . $host . ':' . $port . $uri;
 my $ua = new LWP::UserAgent;
 $req->url($url);
 $req->header(Host => $host);
 $req->user_agent($ua->agent);
 $req->content_type('text/html');
 my ($st_secs,$st_mins,$st_hours)=localtime(time);
my ($seconds, $fraction) = gettimeofday();
 $seconds = $seconds * 1000;
 my $st_ms = $fraction + $seconds;
 my $res = $ua->request($req);
 ($seconds, $fraction) = gettimeofday();
 $seconds = $seconds * 1000;
 my $end_ms = $fraction + $seconds;
 my $resp_time=$end_ms - $st_ms;
 my ($end_secs,$end_mins,$end_hours)=localtime(time);
 my $resp_code=$res->code;



if ($res->is_success)
  {

  print  $FH
"$tid,$st_hours:$st_mins:$st_secs,$end_hours:$end_mins:$end_secs,$st_ms,$end_ms,$resp_time,$resp_code,SUCCESS\n";




  }
else
  {


 print  $FH
"$tid,$st_hours:$st_mins:$st_secs,$end_hours:$end_mins:$end_secs,$st_ms,$end_ms,$resp_time,$resp_code,FAIL\n";



  }


close $FH;

}



my @threads;
my $host='domain.xyz.com';
my $port='80';
my $uri='/';
my $threads=100;
open my $FH, '>', "test.csv" or die "$!";
print $FH "tid,start_time,end_time,start Ms,End Ms,Response
Time,ResponseCode,Result\n";
close $FH;

for (1 .. 100)
{


  my $thr = threads->create(\&HTTP_Req, $_,$host,$port,$uri);
  push(@threads,$thr);


}

$_->join foreach(@threads);



# SNIP



Awaiting for your reply.



Thanks,

PP.


Thread managment in Perl

2008-12-26 Thread perl pra
Hi All,

I am able to create simaltaneous threads and access a subroutine(which
performs firing of  reqeusts). with the created threads.
Some time I get the following error *"Free to wrong pool 225f40 not 13ddbd50
at C:/Perl/lib/constant.pm line -1." .*Whats the reason for the error?
**
Please check the below code and tell me if there is efficient way of
managing the created threads.

Basically i want the following:

 Releasing the thread once it has completed the task and release the
memory associated with it.
 I want to pass thread_id to subroutine(the value of $thr->tid);


Please suggest me the more efficient and organised way of managing the
threads in the following program




###SNIP


use strict;
use warnings;
use LWP;
use LWP::Simple;
use Threads;

sub HTTP_Req
{

 my($tid,$host,$port,$uri)=...@_;
 open my $FH, '>>', "samp2.csv" or die "$!";
 my $req = new HTTP::Request 'POST';
 my $url='http:' . '//' . $host . ':' . $port . $uri;
 my $ua = new LWP::UserAgent;
 $req->url($url);
 $req->header(Host => $host);
 $req->user_agent($ua->agent);
 $req->content_type('text/html');
 my ($st_secs,$st_mins,$st_hours)=localtime(time);
my ($seconds, $fraction) = gettimeofday();
 my $st_ms = $fraction + $seconds * 1000;
 my $res = $ua->request($req);
 ($seconds, $fraction) = gettimeofday();
 my $end_ms = $fraction + $seconds * 1000;
 my $resp_time=$end_ms-$st_ms;
 my ($end_secs,$end_mins,$end_hours)=localtime(time);
 my $resp_code=$res->code;



 if ($res->is_success)
  {

  print  $FH
"$tid,$st_hours:$st_mins:$st_secs,$end_hours:$end_mins:$end_secs,$resp_time,$resp_code,SUCCESS\n";



  }
else
  {


  print  $FH
"$tid,$st_hours:$st_mins:$st_secs,$end_hours:$end_mins:$end_secs,$resp_time,$resp_code,FAIL\n";


  }


close $FH;



}



my @threads;

my $host='test.domain.com';
my $port='80';
my $uri='/';
my $threads=100;
open my $FH, '>', "samp2.csv" or die "$!";
print $FH "tid,start_time,end_time,Response Time,ResponseCode,Result\n";
close $FH;

for (1 .. 100)
{

   my $thr = threads->create(\&HTTP_Req, $_,$host,$port,$uri);
   $thr->detach;
   push @threads, $thr;


}

$_->join foreach @threads;


Thread managment in Perl

2008-12-26 Thread perl pra
Hi All,

I am able to create simaltaneous threads and access a subroutine(which
performs firing of  reqeusts). with the created threads.
Some time I get the following error *"Free to wrong pool 225f40 not 13ddbd50
at C:/Perl/lib/constant.pm line -1." .*Whats the reason for the error?
**
Please check the below code and tell me if there is efficient way of
managing the created threads.

Basically i want the following:

Releasing the thread once it has completed the taks and release the
memory associated with it.
 I want to pass thread_id to subroutine(the value of $thr->tid);




###SNIP

use strict;
use warnings;
use Threads;


sub perform
{

my($tid)=


hwo to get time in milliseconds

2008-12-26 Thread perl pra
hi  All,

I need to get current time in milliseconds.

Any pointers would be highly appreciated

thanks,
siva


NTML Authentication and getting the webpage

2008-09-30 Thread perl pra
Hi Gurus,

I am accessing a web page http://www.outsidedomain.com  using
LWP::userAgent.

I am getting 407 ISA authentication required/500/501 errors after
understanding our network set up , I understood that i need to do NTLM proxy
authentication.

I used module NTLM::Authen, but no luck.

Can somebody demonstrate me how to do NTLM  proxy authentication and  get
the page within a perl script.


Thanks,
pelp


creating simaltaneous threads

2008-06-04 Thread perl pra
hi gurus,

I want to create 100 threads/processes  simaltaneoulsy (at the same time),
and those 100 threads/processes  should  execute a subrountine at the same
time.

can anybody help me giving some ideas reagarding this, I tried creating this
100  process using fork in a for loop but that does not server the purpose.

I even tried with Parallel::ForkManager; but it did not work for me.

Please help me in this.

Thanks,
Siva


creating multiple threads in perl

2008-05-28 Thread perl pra
Hi gurus,

I need to create "n" mulitple threads simaltaneously  and all the threads
should do same operation(just like Jmeter).


i have a subroutine

sub printname{

  my ($tid)[EMAIL PROTECTED];

  print "name is guru tid is $tid\n";

}



all the threads should execute the above subroutine simaltaneoulsy.


Thanks,
siva


Re: csv file question

2008-05-09 Thread perl pra
Hi

please check the following script , you need not to handle null because it
is in quotes,I have tested the following code it works fine



use strict;
use warnings;


my %has;
my $NULL=0;
(open my $FH, '<', "mail.csv") or die "$!";

while(<$FH>)
{

my($one,$two,$three)=split(/\,/,$_);

$has{$one}++;

}
foreach my $key (keys %has)
{
 print "$key is $has{$key} times\n";
}



On 5/6/08, Anirban Adhikary <[EMAIL PROTECTED]> wrote:
>
> Dear list
> I have a csv file having the following contents.
> col1 col2 col3
> "A", "1","2"
> "B","1",   "3"
> "C","2","4"
> "D","1","5"
> "A","1","6"
> "B","2","7"
> "C","2","8"
> " ","3","9"
>
> Now I want to implement a logic which will show me the summarize records
> as
> follows
> col1 count
> A-   2
> B -  2
> C -  2
> D -  1
>
> and one more question how the null value will be handled
>
> Thanks & Regards
> Anirban Adhikary.
>


Re: blessing a hash

2008-04-15 Thread perl pra
Hi Owen,

yeah that true ,but theres little change in the way i build the hash,I build
the hash from variables in the text file.

The below are the datails:

I have a following text file app.config

-

app_path=/home/ap/buuild
host=test.per.com
port=3330

-

I call the new subroutine of the load package with the app.config file


now my package is

package Load;
use strict;
use warnings;

sub new
{
  my $class=shift;
  my $file=shift;
  my %samp;
open my $FH, '<', $file or die "$!";

while(<$FH>)
{

 next unless /(.*)=(.*)/

 my($key,$val)=split(/=/,$_);
 $samp{$key}=$val;
}

}

sub print {

here i need to print $samp{app_path}

}

1;


Thanks In Advance

Siva

On Tue, Apr 15, 2008 at 7:33 PM, Chas. Owens <[EMAIL PROTECTED]> wrote:

>  On Tue, Apr 15, 2008 at 9:54 AM, perl pra <[EMAIL PROTECTED]> wrote:
> > Hi Gurus,
> >
> >  How can I bless a hash.
> >
> >  below is my code:
> >
> >  package load;
> >
> >  use strict;
> >  use warnings;
> >
> >  sub new {
> >
> >   my $class=shift;
> >   my %samp=('1' => "xxx", '2' => "");
> >
> >  }
> >
> >  sub print {
> >
> >   here i need to print $samp{1}
> >
> >
> > }
> >
> >
> >
> >  1;
> >
> >  hwo can i print $samp{1} in print subroutine
> >
> >  Thanks in Advance
> >
> >  Siva
> >
>
> The following should work.  The bless* function takes a reference to a
> Perl variable** and a class to bless it into.  It returns the blessed
> object.  Also, it is customary (but not required) to name the object
> $self inside the of the methods.   You might want to read perldoc
> perltoot*.
>
> package load;
>
> use strict;
> use warnings;
>
> sub new {
> my $class = shift;
> my $self =  { '1' => "xxx", '2' => "" };
> return bless, $self, $class;
> }
>
> sub print {
>my $self = shift;
>print "$_ => $self->{$_}\n" for sort keys %$self;
> }
>
> 1;
>
> * http://perldoc.perl.org/functions/bless.html
> ** Actually all sorts of things can be blessed including functions and
> filehandles, but that is a trickier subject
> *** or http://perldoc.perl.org/perltoot.html
>
> --
> Chas. Owens
> wonkden.net
> The most important skill a programmer can have is the ability to read.
>


blessing a hash

2008-04-15 Thread perl pra
Hi Gurus,

How can I bless a hash.

below is my code:

package load;

use strict;
use warnings;

sub new {

  my $class=shift;
  my %samp=('1' => "xxx", '2' => "");

 }

sub print {

  here i need to print $samp{1}


}



1;

hwo can i print $samp{1} in print subroutine

Thanks in Advance

Siva


wsdl2perl,perl2xml

2008-04-07 Thread perl pra
Hi Gurus,

I have a wsdl file i need to do the following in perl.

I need to convert the wsdl into perl object or perl code.

Then user perl object/perl code to generate the request xml files with
different data types into the tags.

can anybody give me some idea or Is there any other way of doing it.

Thanks in Advance
Siva


Validating xml file against xsd

2008-02-28 Thread perl pra
Hi gurus,

I wanted to validate  xml file against specified  xsd file.

Is there any perl module which does this?


Below are the details:

XML file
---


http://services.ws.faculte.com";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:ws="Webservices.xsd">
 1



XSDFile
-


http://services.ws.faculte.com/xsd";
 xmlns:ns0="http://wsbean.ws.faculte.com/xsd";
 xmlns:xs="http://www.w3.org/2001/XMLSchema";
 attributeFormDefault="qualified" elementFormDefault="qualified"
 targetNamespace="http://services.ws.faculte.com/xsd";>
 
  
   This lists the input requests and output responses for the
   following web services: getCategories,getTopics
  
 
 http://wsbean.ws.faculte.com/xsd";>
 
 
  
   

   
  
 
 
  
   

   
  
 
 
  
   

   
  
 
 
  
   

   
  
 


---

I have used the below perl script




use strict;
use warnings;
use XML::SAX::ParserFactory;
use XML::Validator::Schema;
my $xsd_file = 'Webservices.xsd';
my $xml_file = 'RequestTopics.xml';
my $validator = XML::Validator::Schema->new(file => $xsd_file);
my $parser = XML::SAX::ParserFactory->parser(Handler => $validator);
eval { $parser->parse_uri($xml_file) };
if ($@) {
print "File failed validation: $@"
} else {
print "proceed with parsing XML\n";
}
---

But i got the below error even though the xml file is as per xsd file
-

could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX
elementFormDefault in  must be 'unqualified', 'qualified' is not
supported.



Can any body help me in validating xml file wtih above specified xsd file.

Thanks in Advance,
Siva


validating xml file with xsd

2008-02-28 Thread perl pra
Hi gurus,

I wanted to modify xml file against xsd is there any perl module.


Below are the details:

XML file
---


http://services.ws.faculte.com";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:ws="Webservices.xsd">
 1



XSDFile
-


http://services.ws.faculte.com/xsd";
 xmlns:ns0="http://wsbean.ws.faculte.com/xsd";
 xmlns:xs="http://www.w3.org/2001/XMLSchema";
 attributeFormDefault="qualified" elementFormDefault="qualified"
 targetNamespace="http://services.ws.faculte.com/xsd";>
 
  
   This lists the input requests and output responses for the
   following web services: getCategories,getTopics
  
 
 http://wsbean.ws.faculte.com/xsd";>
 
 
  
   

   
  
 
 
  
   

   
  
 
 
  
   

   
  
 
 
  
   

   
  
 


---

I have used the below perl script




use strict;
use warnings;
use XML::SAX::ParserFactory;
use XML::Validator::Schema;
my $xsd_file = 'Webservices.xsd';
my $xml_file = 'RequestTopics.xml';
my $validator = XML::Validator::Schema->new(file => $xsd_file);
my $parser = XML::SAX::ParserFactory->parser(Handler => $validator);
eval { $parser->parse_uri($xml_file) };
if ($@) {
print "File failed validation: $@"
} else {
print "proceed with parsing XML\n";
}
---

But i got the below error even though the xml file is as per xsd file
-

could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX
elementFormDefault in  must be 'unqualified', 'qualified' is not
supported.



Can any body help me in validating xml file wtih above specified xsd file.

Thanks in Advance,
Siva


testing Non_SOAP webservices

2008-02-26 Thread perl pra
Hi gurus,

I need to test non-SOAP webservices.Can anybody tell how could i do that in
perl.

basically i need to send the following xml file as pay load to the url.

-










http://sample2/xsd";>



Nag

3







---



and get the response



can anybody in the group help me in doing this using perl.





thanks,

Siva



--


oops concepts

2007-09-12 Thread perl pra
Hi Gurus,

I am aware of perl, Now I need to code in perl using oops.

I have few queries Please clear my queries.

What is bless?

When bless used, What differene it makes if we bless a variable?

How do we create a constructor of class.

How do we call a method in class.

how do we use public private and protected in perl OR are there any
alternatives for this in perl?

how do we implement polymorphisim and inheritance in perl.


Please help me in understanding above concepts with small example.


Thanks,
Siva


perl script to crawl the web

2007-08-27 Thread perl pra
Hi Gurus,

I need to write a perl  script for a web spider that will crawl the web
looking for specific file(s) that I specify (such as .mp3) and store the
URL's into a mysql database. This needs to work on a linux server. I will
also require a skip list that will skip certain sites that I input into some
kind of array.

Can anybody give me some ideas to do the same.

Thanks,
PP


Re: Problem with my code

2007-08-05 Thread perl pra
Thanks a lot

Regards,
Siva


On 8/6/07, Mumia W. <[EMAIL PROTECTED]> wrote:
>
> On 08/06/2007 12:32 AM, Jeff Pang wrote:
> > [...]
> > while(my $obj = readdir DIR) {
> > next if $obj =~ /^\.+$/; #or [...]
>
> More, precisely, you might use this:
>
>next if $obj =~ /\A\.\.?\z/;
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>


Re: Problem with my code

2007-08-05 Thread perl pra
hi jhon,

If I use use opendir/readdir I am getting the default directories . and ..
into the directoy handle.

Is there any way tha i could eliminate this.


For example  if i want to copy all contentents of the directory(including
sub directories)
I open a directory Handle using opendir and read it usign readdir, Now my
dirhandle contains default directories . and .. which i cannot copy.

Is there any way that i can elimate the default directories . and .. while
reading the direcotry from a directory handle.

Thanks
Siva


Cygwin like Module in perl

2007-08-04 Thread perl pra
Hi Gurus,


I want  to execute  some of the unix commands on windows, Presently we are
using Cygwin to run unix commands on Windows.

Now I need to convert all the shell scripts into perl scritp. Is there any
module in perl which allows me to execute unix commands on Windows.

My windows version Windows 2003 EE.

Thanks in Advance.
PS.


Re: How do I truncate or remove a trailing character

2007-08-04 Thread perl pra
Hi

Please try the following


___ BEGIN
$value = "12345)" ;

chop $value;

print "$value";

___ END

On 8/2/07, Bret Goodfellow <[EMAIL PROTECTED]> wrote:
>
> Okay, I know this has to be simple, but because I am trying to truncate
> or remove a special character I've run into a roadblock.  Here's what I
> want to do.
>
> $value = "12345)" ;
>
> How do I change $value so that the trailing ")" is removed.  In
> otherwords with the given example, how do I manipulate $value so that
> its value is "12345"?  Please keep in mind that $value may be variable
> in length, so I can't use substr($value, 0, 5).  Can split be used to do
> this?  Stumped.
>


Re: parsing a log file by date

2007-08-04 Thread perl pra
Hi Jeevan,

may be this code would help you.

I tested the code and it works fine.

You can specify start and end months that you want to capture the logs from
log file.

Change the following peice of code to the one which you want..

$2 <= 8)  && ($2 >= 7)

The format is

$2 <=&& $2  >= 

 BEGIN


use strict;
use File::Copy;
use File::Find;

open my $R_H, '<', "./log.txt";


while(<$R_H>)
{
next unless /(\d{1,4})-(\d{1,2})-(\d{1,2})/;

 if ((($2 <= 8)  && ($2 >= 7))  &&  (($3 >=1) && ($3 <= 31)))
 {
  print "$_\n";
 }
}



 END.



Regrads,

Siva




On 7/31/07, jeevs <[EMAIL PROTECTED]> wrote:
>
> Hello forum.
>
> I am here with a logical problem rather. I have a log file which will
> be huge in and can run in MBs.
> log file structure is like
>
> 2007-08-09,0,0,0,0,0,0
> 2007-08-11,0,0,0,0,0,1
> 2007-08-11,0,0,0,0,0,1
> 2007-08-12,0,0,0,2,3,2
>
> What I am supposed to do is show the data between particular date
> range.
> what I have thought so far is to get a two dates for range.
> then getting all the dates in between the range into an array and
> parsing each line to see if the date is there and print the record.
> But my mind says there might be some optimum solution to this.
>
> At first i tried to use record separator as the starting date but soon
> realized if the record to that particular date doesnt exist my program
> is dead.
>
> Right now I am unable to think of anything else.  If you can point me
> to any module or something logical I can do here . It would be
> helpful.
>
> -- nexis
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>


Re: Problem with my code

2007-08-04 Thread perl pra
 hi Mihir Kamdar,

Please the following highlighted.

 I have tested it. this  excatly  does what you need.

configure the parent_path,child_path and out_path to your corresponding
paths.

_ BEGIN




use strict;
use File::Path;
use File::Copy;
use warnings;

my $parent_path="C:/parent";
my $child_path="C:/child";
my $out_path="C:/output";
my @parent_files=<$parent_path/*>;


#  THIS SECTION ACTS AS the Touch Command Check the Files in Parent
Directory and Created the zero bye files in the Child directory#

foreach my $file (@parent_files)
{
  my @arr=$file=~ /(\w+\.\w+)$/;
  if (-f "$child_path/$arr[0]" )
  {
  }
  else
  {

   open my $W_H, '>', "$child_path/$arr[0]" || die "Could not Create
the file $child_path/$arr[0]\n";
   close $W_H;
  }

}

##


## this section Checks the files in the child
directory, Takes the same file from the parent directory removes duplicates
from the file and creates the  file in  output directory
#3

my @child_files=<$child_path/*>;


foreach my $file (@child_files)
{
  my @arr=$file=~ /(\w+\.\w+)$/;
  my %uniques;
  open my $R_H, '<',  "$parent_path/$arr[0]";
  my @file_content=<$R_H>;
  close $R_H;
  foreach my $line (@file_content)  {  $uniques{$line}++; }
  open my $W_H, '>', "$out_path/$arr[0]";
  for(keys(%uniques)) { print $W_H "$_\n"; }
  close $W_H;
}

##


_ END

Regards,
Siva


Re: Problem with my code

2007-08-04 Thread perl pra
hi Mihir Kamdar,

Please the following highlighted.

 I have tested it. this  excatly  does what you need.

configure the parent_path,child_path and out_path to your corresponding
paths.

_ BEGIN




use strict;
use File::Path;
use File::Copy;
use warnings;

my $parent_path="C:/parent";
my $child_path="C:/child";
my $out_path="C:/output";
my @parent_files=<$parent_path/*>;


#  THIS SECTION ACTS AS the Touch Command Check the Files in Parent
Directory and Created the zero bye files in the Child directory#

foreach my $file (@parent_files)
{
  my @arr=$file=~ /(\w+\.\w+)$/;
  if (-f "$child_path/$arr[0]" )
  {
  }
  else
  {

   open my $W_H, '>', "$child_path/$arr[0]" || die "Could not Create
the file $child_path/$arr[0]\n";
   close $W_H;
  }

}

##


## this section Checks the files in the child
directory, Takes the same file from the parent directory removes duplicates
from the file and creates the  file in  output directory
#3

my @child_files=<$child_path/*>;


foreach my $file (@child_files)
{
  my @arr=$file=~ /(\w+\.\w+)$/;
  my %uniques;
  open my $R_H, '<',  "$parent_path/$arr[0]";
  my @file_content=<$R_H>;
  close $R_H;
  foreach my $line (@file_content)  {  $uniques{$line}++; }
  open my $W_H, '>', "$out_path/$arr[0]";
  for(keys(%uniques)) { print $W_H "$_\n"; }
  close $W_H;
}

##


_ END

Regards,
Siva

On 8/2/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a requirement. There are files in the parent directory and they are
> touched in the child directory. So in child directory there are 0 byte
> files
> having the same name as the ones in the parent directory. I need to read
> files in the child directory, and for each file present in the child
> directory, I need to take that file from the parent directory, process
> that
> file(remove duplicate lines from that file), and then write the output for
> each of the input files in the output directory.
>
> I have written the code as below but it gives 0 byte files as output.
> Please
> suggest what is wrong with the below code.
> I have a fear that instead of processing files from parent directory, it
> is
> processing files from the child directory.
>
> I am a newbie at perl. So i might have made silly mistakes. Request you to
> correct them.
>
>
>
> #!/usr/bin/perl
>
> my $child_path =
>
> '/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files/child'
> ;
> my $parent_path =
>
> '/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files'
> ;
> my $write_path =
>
> '/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files/output'
> ;
> my $line;
> my %hash;
> my @file;
> my $key ;
> my $value ;
>
> while () {
>
> opendir my $dh, $child_path or die $!;
>
>while (my $file = readdir $dh) {
>
>my $fname = "$child_path/$file";
>next unless -f $fname;
>unless (exists $times{$file}){
>
>opendir my $dh1,$parent_path or die $!;
>
>while (my $file = readdir $dh1) {
>
>while ($line=readline($file))
>{
>my @cdr=split (/,/, $line) ;
>
> $hash{$cdr[2],$cdr[3],$cdr[6],$cdr[7]}=$line;  #Add some more cdr key
> fields
> if u want.
>}
>close $file ;
>}
>closedir $dh1 ;
>
>open (my $OUT_FILE,">","$write_path/$file.out") or die $!;
>while (($key, $value) = each %hash)
>{
>print $OUT_FILE $value;
>}
>close $OUT_FILE;
>}
>unlink("$parent_path/$file") ;
>unlink("$child_path/$file") ;
>
>
>}
> closedir $dh;
> }
>


reading html hyper links as per directory structure

2007-05-15 Thread perl pra

Hello Gurus,

I have a html page which has hyper links only it does not have any images.

I have to read the html file get the names of the hyper link that is
displayed in the page ,create a directory structure and tar/gz the files.

( I have the directories in server with same names which are  displayed in
html page)

The directory structure should be according to the tab order in the html
page.

*I have attached the html page also.*

If I could get the names of the hyperl inks that are displayed in the html
file as per directory structure then I could tar/.gz the files,. But I have
no idea of html parsing using perl.

Is there any way that I  could create a xml file from the html file so that
I could parse the xml file.

Please Help me in getting the hyper links displayed in the html page
according to the directory structure.


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


XML READ ERROR

2007-01-08 Thread perl pra

Hi Gurus,

I have a problem with reading xml file which has foriegn characters (like
plutôt) using xml::Simple.


I get xml read error.


Then I included encoding=iso8859-1  at the top of xml file.

I am able to read the xml file , but the characters are changed to plut?t
instead of  plutôt, Because of this my test fails.


I need to change the file to UTF-8 format. If I include encoding="UTF-8" at
the top of xml file, Still I get XML read error.

Can somebody guide me to solve this.

Thanks in Advance,
PP


xml read Error (while reading xml file with foriegn characters)

2007-01-07 Thread perl pra

Hi Guru,

I have a problem with reading xml file which has foriegn characters (like
plutôt) using xml::Simple.


I get xml read error.


Then I included encoding=iso8859-1  at the top of xml file.

I am able to read the xml file , but the characters are changed to plut?t
instead of  plutôt, Because of this my test fails.


I need to change the file to UTF-8 format. If I include encoding="UTF-8" at
the top of xml file, Still I get XML read error.

Can somebody guide me to solve this.

Thanks in Advance,
PP


Re: Problem with replacing string in file

2006-11-29 Thread perl pra

thanks rob and Samstag..
have done it

thanks a lot.


On 11/25/06, Rob Dixon <[EMAIL PROTECTED]> wrote:


Mumia W. wrote:
>
> On 11/25/2006 06:40 AM, perl pra wrote:
>>
>> Here is the code i have written...
>>
[snip]
>>
>>  open $LOGFILE, '<', $file;
>>  while ($line1 = <$LOGFILE> ) {
>>if ($line1 =~ m/$key/) {
>>  system("perl -i.bak -p -e 's/$line1/$repline/g' $file");
>>  close $LOGFILE;
>>  last;
>>}
>>  }
>>
[snip]
>>
>> if i run the script I am getting the following errror..
>>
>>
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>>
>> What am i doing wrong?
>>
>
> My eyes are too old to see a stray ' somewhere in a program. My guess is
> that it has something to do with the call to system (which shouldn't be
> called anyway).
>

It's for two reasons. Firstly $line1 isn't chomped, so there is a newline
before
the second slash in the substitution; and secondly Windows doesn't
recognise
single quotes as being special on a command line, so Perl is being passed
a
parameter list like:

-i.bak
-p
-e
's/PROJ_FOLDER=D:\Proj
/PROJ_FOLDER=D:\Proj/g'
E:/temp/FT/config/FTMessageArchive.configd

and clearly the one-liner has no string terminator!

Rob


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





Problem with replacing string in file

2006-11-25 Thread perl pra

hi Gurus,

I have a problem to replace strings of file thru perl script.


Here is the problem in detail...


I have a text file  some thing like this..


PROJ_FOLER=C:\Proj
PROJ_LOGS=C:\PROJ\LOGS


I have same line in config file some thing like this.


PROJ_FOLDER=D:\Proj
PROJ_LOGS=D:\PROJ\LOGS.


Now i read variables from text file split them like this

my ($key,$val)= $line =~ /^(\w+)=(.+)$/mg ;

and place both in a varaible $rep_line="$key=$val";

and search in the config file with $key (which has PROJ_FOLDER) and get to
the result to $line.

Now i will replace $line with $rep_line using

perl -i -p -e 's/$line/$rep_line/g'  $file;

Here is the code i have written...

BEGIN

#!/usr/bin/perl
my $config_path="E:/MessageArchive/WorkArea/config.txt";
$file="E:/temp/FT/config/FTMessageArchive.configd";
open FH, "$config_path";

 while ($line=)
 {


 my ($key,$val)= $line =~ /^(\w+)=(.+)$/mg ;
 $repline="$key=$val";
 open $LOGFILE, '<', $file;
   while ($line1 = <$LOGFILE> )
{
  if ($line1 =~ m/$key/){ system("perl -i.bak -p -e
's/$line1/$repline/g' $file");close $LOGFILE;last;}

   }
 }
  close(FH);
END _

if i run the script I am getting the following errror..


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

What am i doing wrong?

Please help me on this..


Thanks in Advance

PP..


Re: type casting

2006-11-22 Thread perl pra

Thanks John

it worked

Rohit


On 11/22/06, John W. Krahn <[EMAIL PROTECTED]> wrote:


perl pra wrote:
> hi gurus,

Hello,

> I have problem in type casting, here  is the problem..

That is not your problem.

> I get two values  after greping and spliting a file( the values are some
> thing like this "367" and "522>\n")

Your problem is the quotes (") are not numbers so perl is complaining.

> fetching of those two values from file would be in loop ..
>
> now for each interation i have to compare these values and return the
> maximum  (i..e present values with the values of previous interation)
>
> i tried comparing them by converting into integers (ii.e int("367")) i
am
> not able to do it 
>
> I am getting the following error
>
>
> INDEX INITIALLY : "421"
> Argument ""188"" isn't numeric in int at E:\XYZ\ZBC\tt.pl line 50.
>
> INDEX  SUB : "188"
> INDEX MAIN : "188"
> SEARCH INITIALLY : "141">
>
> Argument ""312">\n" isn't numeric in int at E:\XYZ\ZBC\tt.pl line
> 59.
> SEARCH SUB : "312">
>
> SEARCH MAIN : "312"
> Here is my code :
>
>
>
> #!/usr/bin/perl -w
>
> use strict;
> use Switch;
> my $i=1;
> my $INDEXMAX="";
> my $SEARCHMAX="";
> my @MAXISCNO="";
> my @MAXSSCNO="";
> my %var="";
> my $maxiscno="";
> my $maxsscno="";
>
> sub MAX_ELAPSE{
>
>
>
> my $count=$_[1];my $log=$_[2];
> my $logdir=$log . "logs";
> my $logfile=$log . "$count" . ".log";
> my $file="E:/XYZ/ZBC/Logs/$logdir/$logfile";
> my $indexmaxvar="";
> my $searchmaxvar="";
> open LOGFILE,"$file";

You should *ALWAYS* verify that the file opened correctly!

open LOGFILE, '<', $file or die "Cannot open '$file' $!";


> my @grepNames=grep(/(TimeTaken)/, );

You are asking the regular expression to do extra work and capture the
pattern
to the $1 variable.


> close(LOGFILE);
> foreach my $s (@grepNames) {
>
> my @words=split(/ /, $s);

split(/ /) splits on a *single* space character.  You probably want
split(' ')
instead.


> foreach my $w (@words) {
>
>  if ($w=~m/(docsAdded|msElapsedTime)/) {

You are asking the regular expression to do extra work and capture the
pattern
to the $1 variable.


> %var=split(/=/,$w);

You are assigning to the entire hash so at the end of the loop it will
only
contain one key and one value (the last key and value encountered.)  If
you
want to store more than one key and one value then:

 my ( $key, $val ) = split /=/, $w;
 $var{ $key } = $val;

And while here you can remove the quotes:

 ( $var{ $key } = $val ) =~ tr/"//d;

Or:

 ( $var{ $key } ) = $val =~ /(\d+)/;


>  } }
> }
> switch ($log) {

$log only ever contains "data" or "result" so your two cases will never
execute.


> case "index"
>
> {
> $indexmaxvar=$_[0];
>  print "INDEX INITIALLY : $indexmaxvar\n";
>  foreach my $arr (keys (%var)) { if (int($indexmaxvar) <=

%var only contains one key and one value so you don't really need a loop.


> int($var{$arr})) {  $indexmaxvar=$var{$arr};$maxiscno=$count;
print"INDEX
> SUB : $indexmaxvar\n";}
>return ($indexmaxvar,$maxiscno); }

You are returning from inside the foreach loop so only the first
$var{$arr}
will be returned.


> }
> case "search"
> {
>   $searchmaxvar=$_[0];
>  print "SEARCH INITIALLY : $searchmaxvar\n";
>foreach my $arr (keys (%var)) {if (int($searchmaxvar) <=
> int($var{$arr})) {  $searchmaxvar=$var{$arr};$maxsscno=$count;
print"SEARCH
> SUB : $searchmaxvar\n";}
>return ($searchmaxvar,$maxsscno); }
>}
>
> }
>
> }
>
>
> while ($i<=26) {

You may want to use a foreach loop for that:

foreach my $i ( 1 .. 26 ) {


> print "SCENARIO NUMBER  $i
> START_\n";

Instead of typing in a lot of repeated characters:

print '_' x 40, "SCENARIO NUMBER  $i START", '_' x 33, "\n"


> ($INDEXMAX,$MAXISCNO)=MAX_ELAPSE($INDEXMAX,$i,"data");
> print "INDEX MAIN : $INDEXMAX\n";
> ($SEARCHMAX,$MAXSSCNO)=MAX_ELAPSE($SEARCHMAX,$i,"result");

You are passing "data" and "result" as the third argument but your switch
is
looking for "index" and "search".


> print "SEARCH MAIN : $SEARCHMAX\n";
> pr

type casting

2006-11-21 Thread perl pra

hi gurus,

I have problem in type casting, here  is the problem..


I get two values  after greping and spliting a file( the values are some
thing like this "367" and "522>\n")

fetching of those two values from file would be in loop ..

now for each interation i have to compare these values and return the
maximum  (i..e present values with the values of previous interation)

i tried comparing them by converting into integers (ii.e int("367")) i am
not able to do it 

I am getting the following error


INDEX INITIALLY : "421"
Argument ""188"" isn't numeric in int at E:\XYZ\ZBC\tt.pl line 50.

INDEX  SUB : "188"
INDEX MAIN : "188"
SEARCH INITIALLY : "141">

Argument ""312">\n" isn't numeric in int at E:\XYZ\ZBC\tt.pl line
59.
SEARCH SUB : "312">

SEARCH MAIN : "312"
Here is my code :



#!/usr/bin/perl -w

use strict;
use Switch;
my $i=1;
my $INDEXMAX="";
my $SEARCHMAX="";
my @MAXISCNO="";
my @MAXSSCNO="";
my %var="";
my $maxiscno="";
my $maxsscno="";

sub MAX_ELAPSE{



my $count=$_[1];my $log=$_[2];
my $logdir=$log . "logs";
my $logfile=$log . "$count" . ".log";
my $file="E:/XYZ/ZBC/Logs/$logdir/$logfile";
my $indexmaxvar="";
my $searchmaxvar="";
open LOGFILE,"$file";
my @grepNames=grep(/(TimeTaken)/, );
close(LOGFILE);
foreach my $s (@grepNames) {

my @words=split(/ /, $s);

foreach my $w (@words) {

 if ($w=~m/(docsAdded|msElapsedTime)/) {

%var=split(/=/,$w);


 } }
}
switch ($log) {

case "index"

{
$indexmaxvar=$_[0];
 print "INDEX INITIALLY : $indexmaxvar\n";
 foreach my $arr (keys (%var)) { if (int($indexmaxvar) <=
int($var{$arr})) {  $indexmaxvar=$var{$arr};$maxiscno=$count; print"INDEX
SUB : $indexmaxvar\n";}
   return ($indexmaxvar,$maxiscno); }
}
case "search"
{
  $searchmaxvar=$_[0];
 print "SEARCH INITIALLY : $searchmaxvar\n";
   foreach my $arr (keys (%var)) {if (int($searchmaxvar) <=
int($var{$arr})) {  $searchmaxvar=$var{$arr};$maxsscno=$count; print"SEARCH
SUB : $searchmaxvar\n";}
   return ($searchmaxvar,$maxsscno); }
   }

}

}


while ($i<=26) {

print "SCENARIO NUMBER  $i
START_\n";
($INDEXMAX,$MAXISCNO)=MAX_ELAPSE($INDEXMAX,$i,"data");
print "INDEX MAIN : $INDEXMAX\n";
($SEARCHMAX,$MAXSSCNO)=MAX_ELAPSE($SEARCHMAX,$i,"result");
print "SEARCH MAIN : $SEARCHMAX\n";
print "SCENARIO NUMBER  $i
END\n";

$i = $i +1;

}

the data file content would be some thing like this (and this content is
same for all files, only the Time Taken attribute  changes ..

 


the result log would be some thing like this (and this content is same for
all files, only the Time Taken attribute  changes ..
)



Some body please Help me with this . Iam stucked up with it.


thanks in advance,
rohit


Re: How to pass string in command line argument.

2006-10-27 Thread perl pra

I tried this but no luck..

let me tell me explain my problem in detail to you guys so that you  may
give me the apt solution.

i have perl script that searches given string (the string should be passed
in command line argument),

The string should be sent to the script with double quotes attached to it
.(if the string is sent to the script with quotes the spaces in the string
are taken as AND other wise the spaces are taken as OR)

I will write all these strings in xml file with quotes...

I have to retrive these strings and then send to the script 
(i am sending the string to script something like this
 system("perl C:\\Document and settings\\Desktop\\search.pl -n
\"$item->{var2}\"");

If i send the string as above the script is not taking the double quotes ..
it searches with the plain string (with out double quotes and produce the
wrong results .)

hope that explains the problem i have..

Is there any other way to solve the problem ...other than the way which i am
employing..

I am stuck up. please give me some solution.

Waiting for solutions..

Thanks in advance
Perl Pra


On 10/26/06, Mumia W. <[EMAIL PROTECTED]> wrote:


On 10/26/2006 05:47 AM, perl pra wrote:
> hi ,
>
> I want to pass a command argument to perl script with double quotes ("
);
>
>
> below is my scenario
>
> my xml file is something like this ..
>
>
> 
>
> 
>123
> this is my name
> 
> 
>234
> this is others name 
> 
> 
>
> my perl script is something like this
>
>
>
> my $xmlfile = "./samp1.xml";
> my $ref = eval { XMLin($xmlfile) };
>
> if ($@){
>
>print "XML Read ERROR";
>
> } else {
>
> foreach my $item (@{$ref->{reff}}) {
>
> system("perl C:\\Document and settings\\Desktop\\search.pl -n
> \"$item->{var2}\"");
>
> the search.pl file consists of .
>
> print "AGRV[1]";
>
>
>
> my out put is
>
> this is my name
>
> this is others name
>
>
>
> i understand that the string is getting passed to the perl script with
out
> quotes ..
>
>
>
> just a straight string is geeting passed (like this  this is my name)
>
> but i need to send the entire string including  double quotes to the
> script.,something like this ( "this is my name")
>
> Waiting for your solutions
>
> thanks in advance
>
> perl guy
>


Under Linux, you could separate the arguments in the system() call, like
so:

system('perl','C:\\Document and settings\\Desktop\\search.pl',
'-n', '"' . $item->{var2} . '"');

Obviously, you're not running under Linux, so try this:

system(qq{perl "C:\\Documents and Settings\\Desktop\\search.pl" -n
"\\"$item->{var2}\\""});

I'm unsure of how many backslashes you need to escape those quotes.



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





KILLING Processes in unix

2006-10-27 Thread perl pra

hi

I need to kill java processes in Unix and windows both based on OS check.


here is my code

use Switch;

my $UKILLSTR="ps -ef |grep java | grep -v grep|kill -9 `awk '{print $2}'`
";(this command work if i put in command prompt of the linux box )
my $UKILLSTR1="
my $WKILLSTR="taskkill /IM java.exe /F";
my $OS=$^O;


switch ($OS) {

   case "MSWin32" { system("$UKILLSTR"); }
   case "LINUX"  { system("$UKILLSTR");}
   else { print "INVALID OS \n";}

}



for windows my script is killing the Java processes if i run it in unix or
linux iam getting the following error

kill: "`awk" is not a job
kill: "{print }`" is not a job
grep: write error on standard output: The pipe is being closed.


need solution for above .

and Is there any way in perl to kill processes independent of OS .. If there
is hwo can i do that ?


wating for solutions.

Thanks
Perl Pra


killing processes

2006-10-27 Thread perl pra

hi

I need to kill java processes in Unix and windows both based on OS check.


here is my code

use Switch;

my $UKILLSTR="ps -ef |grep java | grep -v grep|kill -9 `awk '{print $2}'`
";(this command work if i put in command prompt of the linux box )
my $UKILLSTR1="
my $WKILLSTR="taskkill /IM java.exe /F";
my $OS=$^O;


switch ($OS) {

   case "MSWin32" { system("$UKILLSTR"); }
   case "LINUX"  { system("$UKILLSTR");}
   else { print "INVALID OS \n";}

}



for windows my script is killing the Java processes if i run it in unix or
linux iam getting the following error

kill: "`awk" is not a job
kill: "{print }`" is not a job
grep: write error on standard output: The pipe is being closed.


need solution for above .

and Is there any way in perl to kill processes independent of OS .. If there
is hwo can i do that ?


wating for solutions.

Thanks
Perl Pra


How to pass string in command line argument.

2006-10-26 Thread perl pra

hi ,

I want to pass a command argument to perl script with double quotes (" );


below is my scenario

my xml file is something like this ..





   123
this is my name


   234
this is others name 



my perl script is something like this



my $xmlfile = "./samp1.xml";
my $ref = eval { XMLin($xmlfile) };

if ($@){

   print "XML Read ERROR";

} else {

foreach my $item (@{$ref->{reff}}) {

system("perl C:\\Document and settings\\Desktop\\search.pl -n
\"$item->{var2}\"");

the search.pl file consists of .

print "AGRV[1]";



my out put is

this is my name

this is others name



i understand that the string is getting passed to the perl script with out
quotes ..



just a straight string is geeting passed (like this  this is my name)

but i need to send the entire string including  double quotes to the
script.,something like this ( "this is my name")

Waiting for your solutions

thanks in advance

perl guy


hwo to configure the Getopt:::STD options for command line arguments.

2006-10-16 Thread perl pra

hi All,


I have to call some perl scripts with command line arguements from another
perl script.

(some thing like this)

perl -s  -a  $ENV{X}  -b $ENV{Y} -c $ENV{Z} ;   ( -a , -b, -c  are also the
arguments to call the script)


( the $ENV{x}=C:\xyz\abc,$ENV{Y}=abc,$ENV{Z}=5).


I understand we have to configure std options,but no idea how to do this.

Can somebody help me on this please?


Thanks in advance,
perl guy


how to configure the options.

2006-10-15 Thread perl pra

hi All,


I have to call some perl scripts with command line arguements from another
perl script.

(some thing like this)

perl -s  -a  $ENV{X}  -b $ENV{Y} -c $ENV{Z} ;   ( -a , -b, -c  are also the
arguments to call the script)


( the $ENV{x}=C:\xyz\abc,$ENV{Y}=abc,$ENV{Z}=5).


I understand we have to configure std options,but no idea how to do this.

Can somebody help me on this please?


Thanks in advance,

Perl Guy


Re: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

2006-10-14 Thread perl pra

thanks a lot .

it works..


--perlpra


On 10/14/06, Dr.Ruud <[EMAIL PROTECTED]> wrote:


"perl pra" schreef:

> Subject: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

Don't shout.


> Is there any other way of using the values in text file as varibales
> in perl script.

Use a hash. See Uri Guttman's reply of yesterday in the "read from a
file and create a hash" thread on clpm.
news:[EMAIL PROTECTED]

|  use File::Slurp ;
|  my %conf = read_file( \*DATA ) =~ m/^(\w+)\s+(.+)$/gm ;

--
Affijn, Ruud

"Gewoon is een tijger."


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





Fwd: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

2006-10-14 Thread perl pra

hi ALL,

I am new to perl and I need some help from you guys,

I have text file which looks like following(its about 100 lines)


OUTPUTDIR=C:\Project\Module\outputdir
INPUTDIR=C:\Project\Module\Inputdir

Now I have to use each and every line of the text file in my perlscript as
command line arguments.

some thing like this


perl -s perlscript1  $OUTPUTDIR  $INPUTDIR


(the values of INPUTDIR andOUTPUT should be same as in text file)

How can i do that ?

My thought is to set each and every line of the textfile as environment
variable.

and i have written the following script


#!/usr/bin/perl -w

my $FILE="C:\\Documents and Settings\\Desktop\\perlscrip\\samp.txt";
open(OF,$FILE) or die("Could not file.");
while($line = ) {
system("SET $line");
}
close(OF);

print "$ENV{va}";

the above script does not show any errors and does not set va as environment
variable.

what would be the problem in the above script?

Is there any other way of using the values in text file as varibales in perl
script.

Waiting for you solutions..


Thanks
Perlstarter.


READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

2006-10-14 Thread perl pra

hi ALL,

I am new to perl and I need some help from you guys,

I have text file which looks like following(its about 100 lines)


OUTPUTDIR=C:\Project\Module\outputdir
INPUTDIR=C:\Project\Module\Inputdir

Now I have to use each and every line of the text file in my perlscript as
command line arguments.

some thing like this


perl -s perlscript1  $OUTPUTDIR  $INPUTDIR


(the values of INPUTDIR andOUTPUT should be same as in text file)

How can i do that ?

My thought is to set each and every line of the textfile as environment
variable.

and i have written the following script


#!/usr/bin/perl -w

my $FILE="C:\\Documents and Settings\\Desktop\\perlscrip\\samp.txt";
open(OF,$FILE) or die("Could not file.");
while($line = ) {
system("SET $line");
}
close(OF);

print "$ENV{va}";

the above script does not show any errors and does not set va as environment
variable.

what would be the problem in the above script?

Is there any other way of using the values in text file as varibales in perl
script.

Waiting for you solutions..


Thanks
Perlstarter.