Python Forum
Problem executing a script on a remote host
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem executing a script on a remote host
#1
Greetings!

I have a remote host(windows) and a system(windows based) connected to it by a private network.
The host has Python 27 on it.
Once a day a Python script runs (scheduled run) on it,
It is mapping the system C: drive as an A: drive and copies files to the host from some directory,
also it does some other stuff. It runs fine, no problems.

I wanted to run the script on the host remotely from my server (windows, with Python 3.9) instead of running it from the Windows scheduler.

I found if I call the script it runs (does some other stuff) but it does not copy files. Sad
No errors. When I run manually it does everything, including copying files. Undecided
Any idea who to fix this?
Here is a script to execute a script on a remote host:
import wmi
from socket import *
ip = 'xx.x.xxx.x'
username = 'user'
password = 'pass'

try:
    print("Establishing connection to %s" %ip)
    connection = wmi.WMI(ip, user=username, password=password)
    print("Connection established")
    connection.Win32_Process.Create(CommandLine=r"C:\Python27\python.exe C:\02\SubPrOc-Get-L_TESTING.py")
except wmi.x_wmi:
    print("Your Username and Password of "+getfqdn(ip)+" are wrong.")
exit   
Thank you.
Reply


Messages In This Thread
Problem executing a script on a remote host - by tester_V - Sep-24-2021, 04:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 395 Jan-26-2024, 07:02 PM
Last Post: deanhystad
Question How can I import a variable from another script without executing it ThomasFab 12 7,893 May-06-2022, 03:21 PM
Last Post: bowlofred
  where to host my python script tomtom 1 1,280 Feb-09-2022, 06:45 AM
Last Post: ndc85430
  Script stop work after 3 actioins - PLEASE WHERE IS THE PROBLEM? rondon442 0 1,577 Sep-27-2021, 05:40 PM
Last Post: rondon442
  Failing to connect to a host with WMI tester_V 6 4,434 Aug-10-2021, 06:25 PM
Last Post: tester_V
  cant use ping, sudo or other commands in remote shell script. throwaway34 7 3,675 May-17-2021, 11:29 AM
Last Post: throwaway34
  problem with sphinx and file directory in script kiyoshi7 0 2,308 Mar-11-2021, 03:52 PM
Last Post: kiyoshi7
  problem about slope in python script for bitcoin trading fisher_garry 1 2,526 Sep-02-2020, 01:39 PM
Last Post: fisher_garry
  Problem running script within console koepjo 3 9,927 Mar-26-2020, 07:11 AM
Last Post: koepjo
  How to gather information from remote host using ansible module in python amritjsr 0 2,056 Jul-20-2019, 01:17 AM
Last Post: amritjsr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020