WinSCP via Windows Command Line Interface

Hello all. I am new to Comodo and new to the Python programming language, so try not to beat on me too much. :slight_smile:

I have a Windows 7 computer with WinSCP installed. I am trying to FTP a zip file to my cloud server via a Comodo Procedure. I can carry it out successfully via the Windows CLI, but when I run it in Comodo, the zip file does not copy.

Anyone have insights on what I’m doing wrong here?

cmd=‘cd “C:\Program Files (x86)\WinSCP”’
cmd=‘winscp.com /command “option batch abort” “option confirm off” “open ftp://username:password@hostname.com:21”’
cmd=‘cd incoming’
cmd=‘cd MBAM_Logs’
cmd=‘lcd C:\ProgramData\Malwarebytes\MBAMService\ScanResults’
cmd=‘put *.zip’
cmd=‘exit’
import os;
import ctypes
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def enter(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def exit(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
with disable_file_system_redirection():
out=os.popen(cmd).read();
print(out);

Hello @superiortechnologyse,

Thank you for bringing this issue to our attention. We will communicate with you shortly via email for the process in resolving this case.

Hello @superiortechnologyse,

Defining a same variable i.e(cmd) multiples times will consider the last updated string which defined to the last variable. In your script the last cmd=“exit” , while executing it considers only “exit” as a command.The preferable way of executing these winscp commands is storing those commands as a text file and then executing it. Please refer to the created script below and please let us know your feedback.

https://scripts.comodo.com/frontend/web/topic/executing-ftp-and-sftp-commands-using-winscp

Thank you,

This helped resolve the issue I was dealing with. Can’t thank you enough!