3dbc has asked for the wisdom of the Perl Monks concerning the following question:
When I logged onto the server I saw a whole bunch of dll errors, which usually happens after windows patches have been deployed but the server wasn't rebooted, so therefore psexec call didn't work...The handle is invalid. Error communicating with PsExec service on Blah.Blah.Blah
cmd started on Blah.Blah.Blah with process ID 4428.
How do I process this output within the perl script to exit gracefully (or try alternative methods) when an error is encountered? Perhaps I'm not totally understanding this 2>&1 part of my qx, can I read this output within the script?print for qx|$externalExe 2>&1|;
#!/usr/bin/perl use strict; use warnings; my @servers = qw( Blah.Blah.Blah Blah1.Blah.Blah Blah2.Blah.Blah Blah3.Blah.Blah Blah4.Blah.Blah ); foreach (@servers){ my $externalExe = qq(psexec.exe \\\\$_ ); $externalExe .= q(-u BLAH\foo -p secret -i -d cmd /c shutdown /r /f /t + 0); print "\n\nStarting external program...\n"; print for qx|$externalExe 2>&1|; # Executes the program, and prints it +'s output print "Program $externalExe run completed.\n"; sleep 360; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SEQUENTIAL REBOOT ORDER WINDOW$
by Marshall (Canon) on Jan 19, 2018 at 02:22 UTC | |
by 3dbc (Monk) on Jan 26, 2018 at 15:14 UTC | |
by 3dbc (Monk) on Feb 07, 2018 at 21:28 UTC | |
by 3dbc (Monk) on Feb 08, 2018 at 21:40 UTC | |
|
Re: SEQUENTIAL REBOOT ORDER WINDOW$
by Anonymous Monk on Jan 17, 2018 at 04:01 UTC |