updated the foreach section, you might have to move around some of the comments because I was experimenting with other commands like ipconfig to see if I can parse the output of a remote machine, which i can ;-) thankfully due to this post kicking my ass in the right direction!:
sub getDOS { print "This is dollar 0 $_[0]\n\n"; open TASK, "$_[0] 2>&1|" or die "cannot open pipe to DOS"; my @return; while (<TASK>) { #chomp; #chop; #print; #return $_; push @return, $_; } return @return; } foreach (@servers){ my $externalExe = qq(psexec.exe \\\\$_ -u ); $externalExe .= $dev_cred . " -p "; #$externalExe .= $prod_pass . ' -i -d cmd /c shutdown /r /f /t 0'; $externalExe .= $dev_pass . ' ipconfig'; print "\n\n... Program START: \n\n $externalExe \n \n"; my @output = getDOS($externalExe); print "\n\nReturned output from DOS command:\n"; foreach(@output){ print; die if $_ =~ /$[Ee]rror/; die if $_ =~ /[Ii]nvalid/; } #wmic process call create "cmd /C > C:\temp\test.txt 2>&1 netstat. +exe -ano" #PsExec v2.2 - Execute processes remotely #Copyright (C) 2001-2016 Mark Russinovich #Sysinternals - www.sysinternals.com #The handle is invalid. #Error communicating with PsExec service on PR0235IPRT002: #print for qx|$externalExe 2>&1|; # Executes the program, and prin +ts it's output print "\n\n.... run complete ...\n"; sleep 360; }


next goal is to make this asynchronous and get rid of the sleep command in the loop. I'm going to build in pings / and more psexec's where I parse the output to ensure the server is up before moving onto the next. Also going to include some net server stop commands to more gracefully stop some of the services before doing a forced shutdown.
- 3dbc

In reply to Re^3: SEQUENTIAL REBOOT ORDER WINDOW$ by 3dbc
in thread SEQUENTIAL REBOOT ORDER WINDOW$ by 3dbc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.