Code: Alles auswählen
os.spawnl(os.P_NOWAIT, 'plink.exe', '-ssh benutzer@htm-network.no-ip.org', '-pw passwort', '-L 127.0.0.5:139:192.168.2.110:139', '-N')
Code: Alles auswählen
os.spawnl(os.P_NOWAIT, 'plink.exe', '-ssh benutzer@htm-network.no-ip.org', '-pw passwort', '-L 127.0.0.5:139:192.168.2.110:139', '-N')
Also benutze lieber das subprocess-Modul.(Note that the subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using these functions. Check especially the Replacing Older Functions with the subprocess Module section.)
Code: Alles auswählen
net stop server /y
Code: Alles auswählen
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "net stop server /y", 0 ,True
WshShell.Run "plink.exe -ssh benutzer@htm-network.no-ip.org -pw passwort -L 127.0.0.5:139:192.168.2.110:139, -N", 0, True
Code: Alles auswählen
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=0x08000000)
Braucht man diese, gehts nur mit Console und verstecken dergleichen, oder man muss dem Kindprozess andere Deskriptoren/Handles unterschieben....
The process is a console application that is being run without a console window. Therefore, the console handle for the application is not set.
...
Code: Alles auswählen
import subprocess
from ctypes import *
class STARTUPINFOW(Structure):
_fields_ = [
('cb', c_ulong),
('lpReserved', c_long),
('lpDesktop', c_long),
('lpTitle', c_long),
('dwX', c_ulong),
('dwY', c_ulong),
('dwXSize', c_ulong),
('dwYSize', c_ulong),
('dwXCountChars', c_ulong),
('dwYCountChars', c_ulong),
('dwFillAttribute', c_ulong),
('dwFlags', c_ulong),
('wShowWindow', c_ulong),
('cbReserved2', c_ushort),
('lpReserved2', POINTER(c_ubyte)),
('hStdInput', c_void_p),
('hStdOutput', c_void_p),
('hStdError', c_void_p)]
s = STARTUPINFOW()
s.dwFlags = c_ulong(1)
s.wShowWindow = c_ulong(5) # hier 0 fuer SW_HIDE - Fenster verstecken
p = subprocess.Popen('cmd.exe', creationflags=0x10, startupinfo=s)
Also über die Funktionalität von stdin kann ich nicht sprechen, aber stdout und stderr nutze ich erfolgreich mit meinem oben angegebenen Schnipsel. :Kjerch hat geschrieben:Mit 'creationflags=0x08000000' funktionieren aber die Console Handles nicht mehr (stdin, stout, stderr), vgl. hierzu die API-Doc:
Code: Alles auswählen
from _subprocess import *
Code: Alles auswählen
import subprocess
from _subprocess import STARTF_USESHOWWINDOW, SW_HIDE
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= STARTF_USESHOWWINDOW
startupinfo.wShowWindow = SW_HIDE
subprocess.Popen('cmd.exe', startupinfo=startupinfo)