Link to home
Start Free TrialLog in
Avatar of izharkhan
izharkhanFlag for United States of America

asked on

Problem in Perl Script

Hello,
I have a part of a perl script and i just want to figure it out that when we run this script we not getting full output. Is there any problem in this script?
Is there any issue with command which use in this script. Can we use win32:iproc  instead? and how?
I am attaching output file. some of the output are missing. how we can get those as well.
I am attaching part of the script and its output please let me know asap.
Thanks


script.txt
output.txt
ASKER CERTIFIED SOLUTION
Avatar of Justin Mathews
Justin Mathews

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of izharkhan

ASKER

Hey Jmatix,
Thanks for your quick reply...
Just for info, that this script is a part of a whole script....and only this part give that output.
I just need to ask that if i will change this part of a script is that gonna any effect on whole script?
I really dont know much about perl scripting. also if you can tell how i can run this and check in server..i will appreciate..


Also if you can give me a script with "win32:iproc" instead that will be helpful for me.

Thanks
Izhar
Avatar of Justin Mathews
Justin Mathews

Adding this script to your existing script should not affect anything else. Or you can put this into a separate file, say, win32procs.pl and call it from the parent script as:

system ("perl.exe", " win32procs.pl");
Hey Jmatix,
Thanks for your help now i can run this script. its work fine.
But the thing is we are not allow to use WMI. I need to use other command for example "win32:iproc". Can you make this one with the help of this command or can change with any other accept WMI.

Thanks
Izhar
I don't have win32:iproc installed. If you can get the Perl module Win32::Process::List you can do this:

  use Win32::Process::List;
  my $P = Win32::Process::List->new();  constructor
  my %list = $P->GetProcesses();        returns the hashes with PID and process name
  foreach my $key ( keys %list ) {
        # $list{$key} is now the process name and $key is the PID
        print sprintf("%30s has PID %15s", $list{$key}, $key) . "\n";
  }

Get the module at: http://search.cpan.org/dist/Win32-Process-List-0.09/List.pm

Hey Jmatix,
Thanks for your help......
In last script you posted i didnt get idea about that...how i can use it :)
and again if you can help me to make a small script with "win32:iproc" it will be great.
thanks in advance :)
Thanks
Izhar
Hello,

when i run this script in windows xp its give me all info......
but when i try to run this in server 2003 at that time its giving me error message
" Can't locate object method "Getobject" via package "win32::OLE" at C:\perl\test.pl line 2."
In server 2003 i am using perl, version 5.005_03
what i can do now???
please let me know
Thanks
Izhar
Win32::OLE module may not be installed on the server. See if you can get that installed from CPAN.

http://search.cpan.org/~jdb/Win32-OLE-0.1709/lib/Win32/OLE.pm
Hey Jmatix,
its work fine.......
still if i can get with iproc that will be great becaz here everyone ask for that actually.........
thats why i need to find out that way if u can help me for that i really appreciate
Thanks
izhar
If you have Win32::IProc installed, you can try:
use Win32::IProc;

$pobj = new Win32::IProc or die "Unable to create proccess object: $!\n";
$pobj-> EnumProccesses(\@processlist) or 
   die "Unable to get process list:$!\n";

foreach $process (@processlist){
  $pid  = $process->{ProcessId};
  $name = $process->{ProcessName};
  print "$pid\t$name\n";
}

Open in new window

Hey Jmatix,
you are really great. :)
i just have one more concern.....
is that any ways that we can write same script with win32::process with your own way.....like your logic with using Win32::Process::Info??? not same as I uploaded....
if you can write that one that will be helpgfull to me....
really really really thanks
Izhar :)

use Win32::Process::Info qw{NT};
$pi = Win32::Process::Info->new ();
@info = $pi->GetProcInfo ();
print ${$_}{ProcessId}, "\t", ${$_}{Name}, "\t", ${$_}{ExecutablePath}, "\n" for @info;

Open in new window

hey Bro,

C:\Perl>process.pl
Can't locate Win32/Process/Info.pm in @INC (@INC contains: C:/Perl/site/lib C:/P
erl/lib .) at C:\Perl\process.pl line 1.
BEGIN failed--compilation aborted at C:\Perl\process.pl line 1.



I am getting this error :(
You need to install the Perl module Win32::Process::Info from CPAN.

Hey Bro,
I am able to run process::iinfo script which i upload here....but i cant run this one dont know why its showing same error.......
what to do now?
Can't locate object method "new" via package "win32::process::Info"
 forgot to load "win32::process::Info"?) at C:\Perl\test.pl line 2.
????
Hey Jmatix,

what i can do with this error. i tried to install win32::process::info but still getting this error
Can't locate object method "new" via package "win32::process::Info"
 forgot to load "win32::process::Info"?) at C:\Perl\test.pl line 2.

May be i am doing mistake,
first i run this command
perl -MCPAN -e shell
then
install win32::process::info
its says sucess
then i exit from cpan
then in command propt
c:\perl>test.pl

this is correct way to run script or still doing mistake?

can you help me please :)
thanks
Izhar
Check if you are using the right case -  Win32::Process::Info and not win32::process::Info.
Thanks jmatix,
That was my mistake :)
now i can run that script...
can you tell me what command i can use to download IProc module?
 becaz i tried this command
isntall Win32::IProc
but its says failed to install module

Test Summary Report
-------------------
t/Test-MultiProcess.t (Wstat: 65280 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 3 tests but ran 1.
Files=1, Tests=1,  0 wallclock secs ( 0.02 usr +  0.03 sys =  0.05 CPU)
Result: FAIL
Failed 1/1 test programs. 1/1 subtests failed.
dmake.exe:  Error code 255, while making 'test_dynamic'
  DBRIAN/Test-MultiProcess-0.01.tar.gz
  C:\STRAWB~1\c\bin\dmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports DBRIAN/Test-MultiProcess-0.01.tar.gz
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 DBRIAN/Test-MultiProcess-0.01.tar.gz         : make_test NO
I could not find Win32::IProc module anywhere to install. It looks like it is no longer being maintained by anyone. From what I understand it used to be available here:

http://jenda.krynicky.cz/

But sadly it is removed from there too.

so that means i cant run IProc anymore????