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

Re: Filemask not working with timestamp

Harinath wrote:

Hi
I am using following syntax and it is not working. It is transferring all files in the folder.

put -filemask="*>=%LASTRUNTIMESTAMP#yyyy-mm-dd hh:mm:ss%" *.*

Note:
LASTRUNTIMESTAMP is determined in the BATCH file using the following syntax i found on this site.
for /F "tokens=* USEBACKQ" %%F in (`winscp.com /command "echo %%TIMESTAMP#%TIMESTAMP_FORMAT%%%" "exit"`) do set LASTRUNTIMESTAMP=%%F

What am I doing wrong ?

This does not make sense.

You probably want to use this:

put -filemask="*>=%LASTRUNTIMESTAMP%" *.*

The %TIMESTAMP_FORMAT% must be yyyy-mm-dd hh:mm:ss.

Though this may do the same in a more reliable way:

put -neweronly *.*

or

synchronize remote

See https://winscp.net/eng/docs/script_upload_most_recent_file
Harinath

Filemask not working with timestamp

Hi
I am using following syntax and it is not working. It is transferring all files in the folder.

put -filemask="*>=%LASTRUNTIMESTAMP#yyyy-mm-dd hh:mm:ss%" *.*

Note:
LASTRUNTIMESTAMP is determined in the BATCH file using the following syntax i found on this site.
for /F "tokens=* USEBACKQ" %%F in (`winscp.com /command "echo %%TIMESTAMP#%TIMESTAMP_FORMAT%%%" "exit"`) do set LASTRUNTIMESTAMP=%%F

What am I doing wrong ?
baji

Need help using file mask with Put command

Thanks a lot prikryl. :D
martin

Re: Need help using file mask with Put command

Because the yyyy-mm-dd means midnight (for the missing time-part the 00:00:00 is implied).

If you want to include today (what does not make sense as you are going to include all files, so you do not need the time constraint), use:

put -filemask="*<=%TIMESTAMP#yyyy-mm-dd% 23:59:59" *.*
baji

Need help using file mask with Put command

Thanks a lot prikryl for your support.


But I have one more question

I have used the following command in my script

put -filemask="*<=%TIMESTAMP#yyyy-mm-dd%" *.*

It copied all the files whose Timestamp is earlier than today but not today's files?

May I know why?
martin

Re: Need help using file mask with Put command

The correct syntax is:
put -filemask="*>=%TIMESTAMP#yyyy-mm-dd%" *.*

See https://winscp.net/eng/docs/file_mask#size_time

Btw, this will upload only today's files. Is this what you are trying to do?
baji

Need help using file mask with Put command

I have few text files in my local directory with timestamp.

for EX:
1.20150805.txt
2.20150828.txt
3.20150806.txt

when I am trying to transfer(put) these files to Tectia SFTP server based on file mask and time stamp. I am not able to transfer,the log shows files are excluded from transfer

please help me.


my code is like this:

put -filemask="*>=%TIMESTAMP#yyyymmdd%" *.*

The log looks like below:

. 2015-08-28 16:52:48.124 --------------------------------------------------------------------------
. 2015-08-28 16:52:48.124 WinSCP Version 5.7.4 (Build 5553) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional)
. 2015-08-28 16:52:48.124 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
. 2015-08-28 16:52:48.124 Log level: Normal
. 2015-08-28 16:52:48.124 Local account: Local\sangepubaji
. 2015-08-28 16:52:48.125 Working directory: C:\Users\sangepubaji
. 2015-08-28 16:52:48.125 Process ID: 8972
. 2015-08-28 16:52:48.125 Command-line: "D:\software_install\WinSCP\WinSCP.exe" /console=574 /consoleinstance=_9600_964 "/script=D:\SFTP_Softwares\sftp_script.txt" "/log=D:\SFTP_Softwares\Sftp_logs\sftp.log"
. 2015-08-28 16:52:48.125 Time zone: Current: GMT+8 (Malay Peninsula Standard Time), No DST
. 2015-08-28 16:52:48.125 Login time: Friday, 28 August, 2015 4:52:48 PM
. 2015-08-28 16:52:48.125 --------------------------------------------------------------------------
. 2015-08-28 16:52:48.125 Script: Retrospectively logging previous script records:
> 2015-08-28 16:52:48.125 Script: option batch abort
< 2015-08-28 16:52:48.125 Script: batch abort
< 2015-08-28 16:52:48.125 Script: reconnecttime 120
> 2015-08-28 16:52:48.125 Script: option confirm off
< 2015-08-28 16:52:48.125 Script: confirm off
> 2015-08-28 16:52:48.125 Script: open sftp://Local\Sangepubaji@localhost -privatekey=D:\SFTP_Softwares\Dummy_Private_Key\100_Local_RSA2048_PrivateKey.ppk
. 2015-08-28 16:52:48.125 --------------------------------------------------------------------------
. 2015-08-28 16:52:48.125 Session name: Local\Sangepubaji@localhost (Ad-Hoc site)
. 2015-08-28 16:52:48.125 Host name: localhost (Port: 22)
. 2015-08-28 16:52:48.125 User name: Local\Sangepubaji (Password: No, Key file: Yes)
. 2015-08-28 16:52:48.125 Tunnel: No
. 2015-08-28 16:52:48.125 Transfer Protocol: SFTP
. 2015-08-28 16:52:48.125 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2015-08-28 16:52:48.125 Disable Nagle: No
. 2015-08-28 16:52:48.125 Proxy: none
. 2015-08-28 16:52:48.125 Send buffer: 262144
. 2015-08-28 16:52:48.125 SSH protocol version: 2; Compression: No
. 2015-08-28 16:52:48.125 Bypass authentication: No
. 2015-08-28 16:52:48.125 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2015-08-28 16:52:48.125 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2015-08-28 16:52:48.125 KEX: dh-gex-sha1,dh-group14-sha1,dh-group1-sha1,rsa,WARN
. 2015-08-28 16:52:48.125 SSH Bugs: A,A,A,A,A,A,A,A,A,A,A
. 2015-08-28 16:52:48.125 Simple channel: Yes
. 2015-08-28 16:52:48.125 Return code variable: Autodetect; Lookup user groups: A
. 2015-08-28 16:52:48.125 Shell: default
. 2015-08-28 16:52:48.125 EOL: 0, UTF: 2
. 2015-08-28 16:52:48.125 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2015-08-28 16:52:48.125 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2015-08-28 16:52:48.125 SFTP Bugs: A,A
. 2015-08-28 16:52:48.125 SFTP Server: default
. 2015-08-28 16:52:48.125 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2015-08-28 16:52:48.125 Cache directory changes: Yes, Permanent: Yes
. 2015-08-28 16:52:48.125 DST mode: 1
. 2015-08-28 16:52:48.125 --------------------------------------------------------------------------
. 2015-08-28 16:52:48.125 Looking up host "localhost"
. 2015-08-28 16:52:48.225 Connecting to ::1 port 22
. 2015-08-28 16:52:49.225 Failed to connect to ::1: Network error: Connection refused
. 2015-08-28 16:52:49.225 Connecting to ::1 port 22
. 2015-08-28 16:52:49.227 Server version: SSH-2.0-6.4.10.264 SSH Tectia Server
. 2015-08-28 16:52:49.227 Using SSH protocol version 2
. 2015-08-28 16:52:49.227 We claim version: SSH-2.0-WinSCP_release_5.7.4
. 2015-08-28 16:52:49.228 Doing Diffie-Hellman group exchange
. 2015-08-28 16:52:49.228 Doing Diffie-Hellman key exchange with hash SHA-256
. 2015-08-28 16:52:50.201 Verifying host key rsa2 0x10001,0xd1c62764dd187014 396c6afab9fe48e3 c563cfeb3ae8049c 7dbad01add6eb911 ea6956619c8ba5cd 236e0aab818ef960 5e944d88734b502f 681f9484ae5b770a a26ede2c2e9aa9e8 cd1f9115fccc417f 334ec9f8196428dc 5d4d23fbcb22d3c3 0c330c378cea2ec4 5575749a1cdb6e0c 67efc43cdd89844b 810ce68c03c3b863 79b6daf7cadc90ea 9c3e0c6ec1467d8d aed1134cd04b9db1 661111c9a156cf4c 8112089f9f53dad3 dc5ef71476f33ce5 2323dc9b576c018b c479b53456768995 with fingerprint ssh-rsa 1536 b4:77:83:e7:4d:01:ea:00:3f:8f:15:59:5b:55:45:38
. 2015-08-28 16:52:50.202 Host key matches cached key
. 2015-08-28 16:52:50.202 Host key fingerprint is:
. 2015-08-28 16:52:50.202 ssh-rsa 1536 b4:77:83:e7:4d:01:ea:00:3f:8f:15:59:5b:55:45:38
. 2015-08-28 16:52:50.202 Initialised AES-256 SDCTR client->server encryption
. 2015-08-28 16:52:50.202 Initialised HMAC-SHA-256 client->server MAC algorithm
. 2015-08-28 16:52:50.202 Initialised AES-256 SDCTR server->client encryption
. 2015-08-28 16:52:50.202 Initialised HMAC-SHA-256 server->client MAC algorithm
. 2015-08-28 16:52:50.202 Reading private key file "D:\SFTP_Softwares\Dummy_Private_Key\100_Local_RSA2048_PrivateKey.ppk"
. 2015-08-28 16:52:50.205 Pageant is running. Requesting keys.
. 2015-08-28 16:52:50.206 Pageant has 1 SSH-2 keys
. 2015-08-28 16:52:50.206 Pageant key #0 matches configured key file
! 2015-08-28 16:52:50.206 Using username "Local\Sangepubaji".
. 2015-08-28 16:52:50.463 Trying Pageant key #0
! 2015-08-28 16:52:50.559 Authenticating with public key "publicKey" from agent
. 2015-08-28 16:52:50.594 Sending Pageant's response
. 2015-08-28 16:52:50.611 Access granted
. 2015-08-28 16:52:50.611 Opening session as main channel
. 2015-08-28 16:52:50.612 Opened main channel
. 2015-08-28 16:52:50.771 Started a shell/command
. 2015-08-28 16:52:50.772 --------------------------------------------------------------------------
. 2015-08-28 16:52:50.772 Using SFTP protocol.
. 2015-08-28 16:52:50.772 Doing startup conversation with host.
> 2015-08-28 16:52:50.772 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2015-08-28 16:52:50.836 Type: SSH_FXP_VERSION, Size: 34, Number: -1
. 2015-08-28 16:52:50.836 SFTP version 3 negotiated.
. 2015-08-28 16:52:50.836 Unknown server extension newline@vandyke.com="\r\n"
. 2015-08-28 16:52:50.836 We believe the server has signed timestamps bug
. 2015-08-28 16:52:50.836 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 string are not mandatory
. 2015-08-28 16:52:50.836 Getting current directory name.
. 2015-08-28 16:52:50.836 Getting real path for '.'
> 2015-08-28 16:52:50.836 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2015-08-28 16:52:50.836 Type: SSH_FXP_NAME, Size: 81, Number: 16
. 2015-08-28 16:52:50.836 Real path is '/D:/Test_SFTP_Folder'
. 2015-08-28 16:52:50.836 Startup conversation with host finished.
< 2015-08-28 16:52:50.836 Script: Active session: [1] Local\Sangepubaji@localhost
> 2015-08-28 16:52:50.837 Script: lcd C:\ftproot
< 2015-08-28 16:52:50.837 Script: C:\ftproot
> 2015-08-28 16:52:50.837 Script: echo 20150828
< 2015-08-28 16:52:50.837 Script: 20150828
> 2015-08-28 16:52:50.837 Script: put -filemask="*>=20150828" *.*
. 2015-08-28 16:52:50.839 Copying 9 files/directories to remote directory "/D:/Test_SFTP_Folder"
. 2015-08-28 16:52:50.839 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FLocal: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask:
. 2015-08-28 16:52:50.839 TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: *>=20150828; ResumeL: 0
. 2015-08-28 16:52:50.839 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2015-08-28 16:52:50.839 File "20150803.xlsx" excluded from transfer
* 2015-08-28 16:52:50.839 (EScpSkipFile)
. 2015-08-28 16:52:50.840 File "20150804.txt" excluded from transfer
* 2015-08-28 16:52:50.840 (EScpSkipFile)
. 2015-08-28 16:52:50.840 File "20150805.docx" excluded from transfer
* 2015-08-28 16:52:50.840 (EScpSkipFile)
. 2015-08-28 16:52:50.841 File "20150805.txt" excluded from transfer
* 2015-08-28 16:52:50.841 (EScpSkipFile)
. 2015-08-28 16:52:50.841 File "20150806.txt" excluded from transfer
* 2015-08-28 16:52:50.841 (EScpSkipFile)
. 2015-08-28 16:52:50.842 File "20150808.txt" excluded from transfer
* 2015-08-28 16:52:50.842 (EScpSkipFile)
. 2015-08-28 16:52:50.842 File "20150828.txt" excluded from transfer
* 2015-08-28 16:52:50.842 (EScpSkipFile)
. 2015-08-28 16:52:50.842 File "20150829.txt" excluded from transfer
* 2015-08-28 16:52:50.842 (EScpSkipFile)
. 2015-08-28 16:52:50.843 File "Approved_July2015.pdf" excluded from transfer
* 2015-08-28 16:52:50.843 (EScpSkipFile)
> 2015-08-28 16:52:50.845 Script: close
. 2015-08-28 16:52:50.845 Closing connection.
. 2015-08-28 16:52:50.845 Sending special code: 12
. 2015-08-28 16:52:50.845 Sent EOF message