Search code examples
batch-filesftpwinscp

How to download only lines with specific ID from a file on SFTP server


I have created a bat file which runs WinSCP script to download a log file (response log) from remote server. The log file obviously downloads as-is (responses from all the requests). How can I limit the download of log file specific to my request? My request has a unique ID, how can I trim the response specific to my unique ID? TIA

Script within my bat file is as below:

 winscp.com/command ^
    "open sftp://xxx.com/ -hostkey=*" "get /var/log/jboss_sit/suFile.log" "exit" ^ 

Solution

  • It seems that you want to filter a text file to lines that contain a substring.

    That's not possible with SFTP protocol. It does not allow filtering files.

    You have to use other interface for that. For example, if you have a shell access, you can use grep command. You can execute shell commands like grep with WinSCP command call. Though if you do not need anything else, using a console terminal client might be more appropriate, than WinSCP.