On Monday 07 Dec 2009 14:29:28 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.
>
OK, a few notes on the script.
> --- SNIP
> #!/usr/bin/perl -w
> use strict;
> use warnings;
It's good that you are using "strict" and "warnings". You don't need "-w" if
you are using warnings.
> use File::Copy;
> use File::Find;
>
> $ENV{path}= $ENV{path} . ';' . 'C:\\Windows\\System32';
It's $ENV{PATH} - not $ENV{path} - though it may not matter on Win32.
This can better be written as:
$ENV{'PATH'} .= ";C:\\Windows\\System32";
And consider using Env::Path:
http://search.cpan.org/dist/Env-Path/
> my $cmd='psexec' . " " . '\\\\' . 10.1.1.121 . ' -u ' . "Adminuser" . '
> -p ' . "adminpassword" . ' -w ' . "C:\\commands\\AutoIT\\ ". "
> \"C:\\commands\\AutoIT\\sch.bat\"";
> system("$cmd") or die "$!";
It seems like you can use the list syntax of perldoc -f system here, which
will save you a lot of problems. This whole code is very unreadable.
Regards,
Shlomi Fish
> --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
>
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
"Star Trek: We, the Living Dead" - http://shlom.in/st-wtld
Bzr is slower than Subversion in combination with Sourceforge.
( By: http://dazjorz.com/ )
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/