May-28-2018, 07:55 AM
Hi All,
I am relatively new to python and this forum as well. I was recently working on a code which requires me to connect to a remote machine via python and execute a certain batch file. Following is the code which when executed doesn't give any error, but doesn't do the expected either. This is being run from jython 2.5.1 which is part of an application suite (hyperion FDMEE).
Also, I tried to debug this on my local machine itself, still no avail.
Thanks,
Dev
I am relatively new to python and this forum as well. I was recently working on a code which requires me to connect to a remote machine via python and execute a certain batch file. Following is the code which when executed doesn't give any error, but doesn't do the expected either. This is being run from jython 2.5.1 which is part of an application suite (hyperion FDMEE).
import com.hyperion.aif.scripting.API as API import os import smtplib import datetime from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from subprocess import call from subprocess import Popen psbatchpath = "C:\tools\PSTools" psbatchfile = os.path.join(psbatchpath,'PsExec64.exe') dbbatchpath = "D:\Test_Batch_Script" dbbatchfile = os.path.join(dbbatchpath,'test_hello.bat') hostname = "\\XX.XXX.XXX.XXXX" try : #Popen(['C:\tools\PSTools\PsExec64.exe', '\\XX.XXX.XXX.XXX', '-e' ,'-s' ,'-d' ,'-i' ,'D:\Automation\hello.bat'], shell=True) #Popen(['C:\\tools\\PSTools\\PsExec64.exe', '\\\\XX.XXX.XXX.XXX', '-e' ,'-s' ,'-d' ,'-i' ,'D:\\Automation\\hello.bat'], shell=True) Popen([psbatchfile, '\\\\XX.XXX.XXX.XXX' , '-i' , dbbatchfile], shell=True) #Popen([dbbatchfile], shell=True) #call([dbbatchfile], shell=True) except ImportError, e: fdmAPI.logDebug(" couldnt connect with PsExec")when I run the same psexec command directly from the command prompt, it runs perfectly fine.
Also, I tried to debug this on my local machine itself, still no avail.
#import com.hyperion.aif.scripting.API as API import os import smtplib import datetime from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText #from subprocess import call #from subprocess import Popen import subprocess print "this" print "this" #cmd = r'c:\PSTools\psexec \\localhost -d cmd /c echo test' cmd = r'c:\PSTools\psexec \\localhost -d c:\\test_psexc.bat' myproc = subprocess.Popen(cmd, stdin=None, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) myproc.communicate() print "this as well"Request your expert help on this please.
Thanks,
Dev