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 <dery...@gmail.com> 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/
>
>
>

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to