Re: could not execute psexec
On Dec 7, 9:11 pm, perl...@gmail.com (Perl Pra) wrote: 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. Did you correct the system call ? Examine the $? return...? system($cmd) or die $!;# incorrect: see earlier response -- 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
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
Re: could not execute psexec
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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: could not execute psexec
On Mon, Dec 7, 2009 at 6:29 AM, perl pra perl...@gmail.com 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* [snip] my $cmd='psexec' . . '' . 10.1.1.121 . ' -u ' . Adminuser . ' -p ' . adminpassword . ' -w ' . C:\\commands\\AutoIT\\ . \C:\\commands\\AutoIT\\sch.bat\; system($cmd) or die $!; Try using 'psexec.exe' as the command. It's been a while since I've used my Windows scripts. And I seem to remember having to use the extension. Or maybe that's just old age... -- Robert Wohlfarth
Re: could not execute psexec
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/
Re: could not execute psexec
Funniest thing -- when I run psexc from the command line I get: C:\Documents and Settingspsexec 'psexec' is not recognized as an internal or external command, operable program or batch file. C:\Documents and Settingspsexec.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/
Re: could not execute psexec
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 bob.gool...@gmail.com wrote: Funniest thing -- when I run psexc from the command line I get: C:\Documents and Settingspsexec 'psexec' is not recognized as an internal or external command, operable program or batch file. C:\Documents and Settingspsexec.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/
Re: could not execute psexec
Note the last-but-one line that I quoted from the PSexec Doc: Just copy PsExec onto your executable path. I strongly suspect that you are NOT running the same environment in Perl as you are when you run from the command line. Check your PATH variables and fix your installation to include ALL of the directories that you need. B On Mon, Dec 7, 2009 at 9:11 PM, perl pra perl...@gmail.com wrote: 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 bob.gool...@gmail.com wrote: Funniest thing -- when I run psexc from the command line I get: C:\Documents and Settingspsexec 'psexec' is not recognized as an internal or external command, operable program or batch file. C:\Documents and Settingspsexec.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/