Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

What if you log to a C: drive, but upload a file from a network drive?
generic

Hi Martin,

Thank you for getting back to me so quickly. I am currently running the python code manually through IDLE from the run dropdown. The program runs fine and then a command window opens from WinSCP with the following output:

batch abort
confirm on
Error occurred during logging. It's been turned off.
Can't open log file {absolute path to networked drive log directory}
Searching for host...
Connecting to host...
Authenticating...
Using username {username}
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] username@IP

So, from this output it seems like it works, but when I check the WinSCP GUI, it seems the zip file never makes it into the associated directory in root. When everything remains isolated in the C: drive it works perfectly and I am able to access the zip in the GUI, but when I change relevant paths to a corresponding network drive it does not.

Thank you again for getting back to me. I look forward to your response.

Best regards,
Generic
martin

Re: Synchronize only works when paths are restricted to C: drive

What does WinSCP output, when your run it? How do you run the Python script? Do you run it manually? Or by some service? Like Windows Scheduler?
In the later case, did you read this?
https://winscp.net/eng/docs/faq_scheduler
generic

Synchronize only works when paths are restricted to C: drive

Good afternoon everyone,

I am attempting to troubleshoot a python script I have not written myself, but which I have been tasked with fixing. The script takes files from some map document, zips them, and then transfers them using the synchronize function defined in a text document. The relevant bit of the code for WinSCP is below:

[b]Python Script (only the important part)[/b]
from subprocess import Popen
import os
#root = os.path.abspath(os.path.curdir)
root = r"{absolute path to directory in networked drive}"
print root

bat = '"C:\Program Files (x86)\WinSCP\WinSCP.com" /script="{absolute path in networked drive to text file holding unix commands}" /log="{absolute path to log file in networked drive}"'
def upload_sftp(BAT,DIR):
p = Popen(BAT, cwd=DIR)
stdout, stderr = p.communicate()
if p.returncode == 0:
print("\n Transfer was Successful")
else:
print("\n Transfer was unsuccessful.\n Look up this return code for more details --> " + str(p.returncode) )
upload_sftp(bat, root)

[b]Unix Commands in text file[/b]
option batch abort
option confirm on
open {insert sftp link and hostkey here}
synchronize remote local_absolute_path_to_networked_drive_dir /HOME/OPEN_DATA
exit

So, the aforementioned script and the above commands work just fine when the workflow is restricted to the C: drive (exporting my files to a location in the C: drive, zipping in the C: drive, synchronizing from C: drive), but I have been asked to get it functioning on one of our network drives. Changing the absolute paths to locations in this network drive yields a "1" error code which seems to be an EOF error. I have been unable to produce log files in either the C or networked drive. I apologize for not being able to provide this.

Apologies if I am not doing an adequate job describing the workflow, I am still reading through the software documentation and learning myself. Please request any additional information and I will do my best to supply it. Thank you