Skip to main content
added 386 characters in body
Source Link
DJMcCarthy12
  • 4.2k
  • 8
  • 31
  • 35

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here  successes.append(host) return successes 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.check_output(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here successes.append(host) return successes 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Here is the additional code including the multiprocessing portion:

PROCESSES = 2 host_sublists_execute = [.... list of hosts ... ] poolE = multiprocessing.Pool(processes=PROCESSES) success_executions = poolE.map(execute,host_sublists_execute) success_executions = [entry for sub in success_executions for entry in sub] poolE.close() poolE.join() 

Thanks!

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.check_output(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Thanks!

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here  successes.append(host) return successes 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.check_output(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here successes.append(host) return successes 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Here is the additional code including the multiprocessing portion:

PROCESSES = 2 host_sublists_execute = [.... list of hosts ... ] poolE = multiprocessing.Pool(processes=PROCESSES) success_executions = poolE.map(execute,host_sublists_execute) success_executions = [entry for sub in success_executions for entry in sub] poolE.close() poolE.join() 

Thanks!

fixed typo
Source Link
DJMcCarthy12
  • 4.2k
  • 8
  • 31
  • 35

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.callcheck_output(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Thanks!

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Thanks!

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.check_output(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Thanks!

added 8 characters in body
Source Link
dano
  • 95.5k
  • 21
  • 234
  • 231

I'm having some strange issues using subprocess.check_output()subprocess.check_output(). At first I was just using subprocess.call()subprocess.call() and everything was working fine. However when I simply switch out call()call() for check_output()check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Thanks!

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Thanks!

I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.

Before code (works fine):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

After code (doesn't work):

def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here 

This gives the error: Error

I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?

Thanks!

Source Link
DJMcCarthy12
  • 4.2k
  • 8
  • 31
  • 35
Loading