dracosalpha
YaBB Newbies
Offline
Posts: 7
Montreal, Canada
|
Hi Gert,
Thanks a lot for your answer. Yes, I was trying to run it as a service, but since it didn't work, I also tried other modes, results are the same. I'm from the very old school of 8.3, and don't usually have spaces in anything. Here is the whole batch file:
---- @echo off TITLE MEDSFTPUpload cd \FTP_ROOT\clientname\prod\client\export\control
SET SOURCEDIR=C:\FTP_ROOT\clientname\prod\client\export\ SET TARGETDIR=C:\FTP_ROOT\clientname\prod\client\export\archives\
set SCRIPT=C:\FTP_ROOT\clientname\prod\client\export\control\sftpcontrol.scr
( echo cd inbound echo put c:/FTP_ROOT/clientname/prod/client/export/%WD_FILE_N% echo quit ) > %SCRIPT%
cd \FTP_ROOT\clientname\prod\client\export REM timeout /t 10 /nobreak C:\Windows\System32\OpenSSH\sftp.exe -b c:\FTP_ROOT\clientname\prod\client\export\control\sftpcontrol.scr varinc@cssh.automation.website.ca
copy "%SOURCEDIR%%WD_FILE_N%" "%TARGETDIR%%WD_FILE_B%%WD_DTTM%.%WD_FILE_E%" erase "%SOURCEDIR%%WD_FILE_N%"
----
Files generated by the process don't have spaces either, as you can see in the latest script file I tested: sftpcontrol.scr
----
cd inbound put c:/FTP_ROOT/clientname/prod/client/export/MED-DM-WF-SUIVI-ACHAT-20230719-Q0-ex.C SV quit
----
Obviously I can't execute this batch file manually, since the runtime variables aren't available if not initiated by WatchDirectory, so I run this edited version instead to test the command. In it I REM out the lines that have runtime variables, and the script picks up the control file from the previous execution.
---- @echo off TITLE MEDSFTPUpload cd \FTP_ROOT\clientname\prod\client\export\control
SET SOURCEDIR=C:\FTP_ROOT\clientname\prod\client\export\ SET TARGETDIR=C:\FTP_ROOT\clientname\prod\client\export\archives\
set SCRIPT=C:\FTP_ROOT\clientname\prod\client\export\control\sftpcontrol.scr
REM ( REM echo cd inbound REM echo put c:/FTP_ROOT/clientname/prod/client/export/%WD_FILE_N% REM echo quit REM ) > %SCRIPT%
cd \FTP_ROOT\clientname\prod\client\export REM timeout /t 10 /nobreak C:\Windows\System32\OpenSSH\sftp.exe -b c:\FTP_ROOT\clientname\prod\client\export\control\sftpcontrol.scr varinc@cssh.automation.website.ca
REM copy "%SOURCEDIR%%WD_FILE_N%" "%TARGETDIR%%WD_FILE_B%%WD_DTTM%.%WD_FILE_E%" REM erase "%SOURCEDIR%%WD_FILE_N%"
----
This batch file successfully transfers the file. I tried waiting 10, 20, and 30 seconds between the creation of the control file and the initiation of the command, just in case the file system doesn't realize the file is there yet one batch file line later. I've seen something like that happen before. That wasn't it though.
Unless you can see something, my fallback will probably be to generate the script file only, and to try running a batch file through the Windows Task Scheduler every 10 minutes or so, but that leaves me open to missing files, if multiple files are dropped in the same 10 minutes. Shouldn't happen but, again, I've had surprises before.
Let me know if you see anything. And, as always, I really appreciate your excellent knowledge of your product.
Alex.
|