Script question

Advertisement

kaplan71
Joined:
Posts:
11

Script question

Hello --
I created a script that is designed to copy several directories to a remote server. The /command section of the script reads as follows:
log="C:\Users\Administrator\Documents\WinSCP.log" /ini=nul ^
 /command ^
    "open sftp://root:<remote host>/ -hostkey=""xxxxx""" ^
    "lcd H:\MIM_DATA\BACKUP" ^
    "cd /xfs4/MimVista/<localhost>" ^
    "put -neweronly *" ^
    "lcd C:\ProgramData" ^
    "cd /xfs4/MimVista/<localhost>" ^
    "put -neweronly MIM" ^
    "exit"
The script was scheduled to run via the Windows Task Scheduler. The result was a partial success. One of the directories was copied over in its entirety, while the second one had problems completing. The log file that was generated for this script is included as an attachment.

There were several files that could not be copied due to their being in use at the time, and these can be excluded from the process. The script also timed out before completing the copy of all the directories although I suspect that was due to the files that were in use, and the system waiting for user interaction. As it is, when I ran the copy interactively, I skipped the files, and all directories were copied over.

My questions are the following:

1. Would the files in question have prevented the remaining directories to be copied due to the need for user input?
2. What syntax should I use to exclude the files in question?

Thanks.

Reply with quote E-mail

Advertisement

kaplan71
Joined:
Posts:
11

RE: Script Question

Hello --
Thank-you for your reply. I added the following two lines to the script:

"put -filemask=*.lock" ^
"put -filemask=*.log" ^

The log file had the following entries within it:

< 2017-12-27 02:01:55.498 Script: Missing parameter for command 'put'.
. 2017-12-27 02:01:55.498 Script: Failed
. 2017-12-27 02:01:55.498 Script: Exit code: 1
. 2017-12-27 02:01:55.498 Closing connection.

Looking at the documentation, it appears I need to add either the "-resume" or "-resumesupport=on" parameter.

Which one should I use, and what is the difference between the two?

Thanks.

Reply with quote E-mail

kaplan71
Joined:
Posts:
11

Hello --
I tried the following two syntaxes in my script:

"put -filemask=*.lock -resumesupport=on" 
"put -filemask=*.log -resumesupport=on

"put -filemask=*.lock -resume" 
"put -filemask=*.log -resume"

I reran the script with both, and I now getting the following error:
2017-12-28 08:26:44.347 Script: Missing parameter for command 'put'.
. 2017-12-28 08:26:44.347 Script: Failed
. 2017-12-28 08:26:44.347 Script: Exit code: 1

Where is the error in my syntax? Also, can you please explain the difference between resume and resumesupport?

Thanks.

Reply with quote E-mail

martin
Site Admin
martin avatar
Joined:
Posts:
29,476
Location:
Prague, Czechia

It should be:
  "put * -filemask=|*.lock,*.log -resumesupport=on" ^

Reply with quote

Advertisement

kaplan71
Joined:
Posts:
11

My mistake. I did a check of the log file, and I noticed the following entries:

2017-12-28 12:35:01.663 Script: put * -filemask=|*.lock,*.log -resumesupport=on
. 2017-12-28 12:35:01.664 Copying 13 files/directories to remote directory "/xfs4/MimVista/mghrostorage1"
. 2017-12-28 12:35:01.664 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: Y (102400); CalcS: No; Mask:
. 2017-12-28 12:35:01.664 TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: |*.lock,*.log; ResumeL: 0
. 2017-12-28 12:35:01.664 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2017-12-28 12:35:01.664 File: 'Application Data' [2013-08-22T14:48:41.118Z] [0]
* 2017-12-28 12:35:01.665 (EDirectoryNotFoundException) The drive cannot be found
. 2017-12-28 12:35:01.665 Asking user:
. 2017-12-28 12:35:01.665 File or folder 'Application Data' does not exist. ("The drive cannot be found")
< 2017-12-28 12:35:01.665 Script: File or folder 'Application Data' does not exist.
< 2017-12-28 12:35:01.666 Script: The drive cannot be found
* 2017-12-28 12:35:01.668 (EScpSkipFile) File or folder 'Application Data' does not exist.
* 2017-12-28 12:35:01.668 The drive cannot be found
. 2017-12-28 12:35:01.668 Copying finished: Transferred: 0, Elapsed: 0:00:00, CPS: 0/s
. 2017-12-28 12:35:01.668 Script: Failed
. 2017-12-28 12:35:01.668 Script: Exit code: 1

I missed something?

Reply with quote E-mail

martin
Site Admin
martin avatar
Joined:
Posts:
29,476
Location:
Prague, Czechia

If the "Application Data" is not accessible, exclude it too:
  "put * -filemask=""|*.lock,*.log,Application Data/"" -resumesupport=on" ^

Reply with quote

Guest

Hello --
The addition of the Application Data entry to the filemask line did not seem to work, as the error messages continue to appear in the log file. Since the folders in question reside in the C:\ProgramData directory, which is a hidden folder similar to the AppData folder, the debugging that is going on in that conversation might apply here.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,476
Location:
Prague, Czechia

Anonymous wrote:

Hello --
The addition of the Application Data entry to the filemask line did not seem to work, as the error messages continue to appear in the log file. Since the folders in question reside in the C:\ProgramData directory, which is a hidden folder similar to the AppData folder, the debugging that is going on in that conversation might apply here.
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

kaplan71
Joined:
Posts:
11

Hello --
I have enclosed a copy of the log file. The most recent entries show an exit code of 0 due to my not including the directory in question in the backup. The hope is that I will be able to include it in the final production version of the script.
  • WinSCP.log (558.16 KB, Private file)
  • WinSCP.log (558.16 KB, Private file)

Reply with quote E-mail

kaplan71
Joined:
Posts:
11

Hello --
I corrected the syntax, and the contents of the directory in question are getting copied over. However, there is a new problem. The script continues to have a running status in the Task Scheduler, even though it appears to have completed its job.

I have adjusted the Task Scheduler setting to automatically stop the job after four hours, but I am curious as to what would cause the script to continue to run.

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,476
Location:
Prague, Czechia

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

kaplan71
Joined:
Posts:
11

Hello --
I believe I found the problem. There were several instances of WinSCP running, and once I ended the respective processes, the Task Scheduler indicated the job had completed successfully. Also, the syntax that I used for the
directory in question is shown below:
"put -neweronly * -filemask=""|*.lock,*.log"" -resumesupport=on" ^

The directory, and its sub-folders, were successfully copied to the remote location.
Thanks again for the help.

Reply with quote E-mail

Advertisement

You can post new topics in this forum