title: WinSCP Session.ExecuteCommand() is timing out
body: <p>I am running a remote script with WinSCP that results in a lengthy wait between terminal responses. </p>
  
  <p>I get all the intermediate output from the session with the session.OutputDataReceived() event, until it comes to a point where the remote host is silent for > 30 seconds before continuing. </p>
  
  <p>This is the conversation with the remote host as captured by OutputDataReceived:</p>
  
  <pre><code>20161123.144738.342 &lt;ip&gt; : winscp&gt; call ./AAA1504v1_1_7.run --load
  20161123.144743.646 &lt;ip&gt; : Searching for firmware
  20161123.144743.650 &lt;ip&gt; : Validating firmware
  20161123.144743.653 &lt;ip&gt; : Image:
  20161123.144743.655 &lt;ip&gt; :  Image version :1
  20161123.144743.658 &lt;ip&gt; :  Product       :AAA 1504
  20161123.144743.661 &lt;ip&gt; :  Version       :1.1.7
  20161123.144743.664 &lt;ip&gt; : AAA image:
  20161123.144743.667 &lt;ip&gt; :  Version  :1.1.7
  20161123.144743.670 &lt;ip&gt; :  Checksum :0x6386
  20161123.144743.672 &lt;ip&gt; :  Length   :100329
  20161123.144743.675 &lt;ip&gt; :  date     :Tue May 17 13:49:54 2016
  20161123.144743.677 &lt;ip&gt; :  name     :'AAA1504v117.bin'
  20161123.144743.678 &lt;ip&gt; : MPD image:
  20161123.144748.638 &lt;ip&gt; :  Version  :1.1.9
  20161123.144748.640 &lt;ip&gt; :  Checksum :0x8D29
  20161123.144748.643 &lt;ip&gt; :  Length   :2295808
  20161123.144748.646 &lt;ip&gt; : A393B7ED1E98D478D3DC7A567EAD7A0E valid
  20161123.144748.648 &lt;ip&gt; : Valid firmware
  20161123.144806.731 &lt;ip&gt; : Updating AAA.........success
  20161123.144845.105 &lt;ip&gt; : Host is not communicating for more than 15 seconds.
  20161123.144845.108 &lt;ip&gt; : Still waiting...
  20161123.144845.110 &lt;ip&gt; : Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
  20161123.144845.113 &lt;ip&gt; : Warning: Aborting this operation will close connection!
  </code></pre>
  
  <p>After 'Updating AAA.....success', I expect three more lines, after various wait times. </p>
  
  <p>I'm assuming the remaining output lines are from the remote host, suggesting the WinSCP session is about to time out.  </p>
  
  <p>I need the session to stay alive to the host until the process is complete, and I tried setting <strong>"TimeoutInMilliseconds=60000"</strong> in the SessionOptions, but the result was then </p>
  
  <pre><code>20161123.150452.108 &lt;ip&gt; : A393B7ED1E98D478D3DC7A567EAD7A0E valid
  20161123.150452.110 &lt;ip&gt; : Valid firmware
  20161123.150510.196 &lt;ip&gt; : Updating AAA.........success
  20161123.150711.246 &lt;ip&gt; : Error - Timeout waiting for WinSCP to respond
  </code></pre>
  
  <p>The remote script ends with rebooting the remote host, so there is no real exit or return to a command prompt, just a final "Rebooting AAA" message, which I can use to signal the end of the process.  How can I make WinSCP hold this session up until it completes? </p>
  
  <p>===  Edit 2016/11/28 ====</p>
  
  <p>I have a try/catch around the session.ExecuteCommand() line.  When I use session defaults, and the script reaches the pause (of around 70 seconds), I see these strings returned in OutputDataReceived:</p>
  
  <pre><code>20161128.144807.559 [OutputDataReceived] Updating AAA.........success
  20161128.144807.559 Firmware Update complete
  20161128.144846.496 [OutputDataReceived] Host is not communicating for more than 15 seconds.
  20161128.144846.497 [OutputDataReceived] Still waiting...
  20161128.144846.497 [OutputDataReceived] Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
  20161128.144846.497 [OutputDataReceived] Warning: Aborting this operation will close connection!
  20161128.144946.029 [OutputDataReceived] (A)bort (60 s): Abort
  20161128.144946.031 [OutputDataReceived] Terminated by user.
  20161128.144946.033 [OutputDataReceived] Session 'root@xxx.xx.xxx.229' closed.
  20161128.144946.034 [OutputDataReceived] No session.
  </code></pre>
  
  <p>If I use the extended session option "TimeoutInMilliseconds = 900000", I see this: </p>
  
  <pre><code>20161128.144011.321 [OutputDataReceived] Updating AAA.........success
  20161128.144011.322 Firmware Update complete
  20161128.144111.530 [catch2] Timeout waiting for WinSCP to respond
  </code></pre>
  
  <p>Meaning, the ExecuteCommand() method is throwing the exception, and it only waits 60 seconds for the script to send data; the TimeoutInMilliseconds apparently only applies to the session, not to the ExecuteCommand timeout. </p>
  
  <p>Here is the WinSCP debug log for the 'default' session:</p>
  
  <pre><code>. 2016-11-28 14:46:15.142 --------------------------------------------------------------------------
  . 2016-11-28 14:46:15.142 WinSCP Version 5.9.2 (Build 6958) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional)
  . 2016-11-28 14:46:15.142 Configuration: nul
  . 2016-11-28 14:46:15.142 Log level: Normal
  . 2016-11-28 14:46:15.142 Local account: ....\......
  . 2016-11-28 14:46:15.142 Working directory: C:\Program Files (x86)\WinSCP
  . 2016-11-28 14:46:15.142 Process ID: 40352
  . 2016-11-28 14:46:15.143 Command-line: "C:\Program Files (x86)\WinSCP\winscp.exe" /xmllog="C:\Users\........\AppData\Local\Temp\wscpA5D8.0139A378.tmp" /xmlgroups /xmllogrequired /nointeractiveinput /dotnet=592  /ini=nul /log="C:\#support\winscp.dbg"  /console /consoleinstance=_42456_30762424_206
  . 2016-11-28 14:46:15.143 Time zone: Current: GMT-6, Standard: GMT-6 (Central Standard Time), DST: GMT-5 (Central Daylight Time), DST Start: 3/13/2016, DST End: 11/6/2016
  . 2016-11-28 14:46:15.143 Login time: Monday, November 28, 2016 2:46:15 PM
  . 2016-11-28 14:46:15.143 --------------------------------------------------------------------------
  . 2016-11-28 14:46:15.143 Script: Retrospectively logging previous script records:
  &gt; 2016-11-28 14:46:15.143 Script: option batch on
  &lt; 2016-11-28 14:46:15.143 Script: batch           on        
  &lt; 2016-11-28 14:46:15.143 Script: reconnecttime   120       
  &gt; 2016-11-28 14:46:15.143 Script: option confirm off
  &lt; 2016-11-28 14:46:15.143 Script: confirm         off       
  &gt; 2016-11-28 14:46:15.143 Script: option reconnecttime 120
  &lt; 2016-11-28 14:46:15.143 Script: reconnecttime   120       
  &gt; 2016-11-28 14:46:15.143 Script: open scp://root:***@xxx.xx.xxx.229 -hostkey="ssh-rsa 1040 ef:aa:a1:30:79:12:c7:f8:02:36:d0:ac:71:6b:5b:24" -timeout=15 -rawsettings AuthGSSAPI="1" Cipher="aes,blowfish,3des,chacha20,WARN,arcfour,des" KEX="ecdh,dh-gex-sha1,dh-group14-sha1,dh-group1-sha1,rsa,WARN"
  . 2016-11-28 14:46:15.143 --------------------------------------------------------------------------
  . 2016-11-28 14:46:15.143 Session name: root@xxx.xx.xxx.229 (Ad-Hoc site)
  . 2016-11-28 14:46:15.143 Host name: xxx.xx.xxx.229 (Port: 22)
  . 2016-11-28 14:46:15.143 User name: root (Password: Yes, Key file: No)
  . 2016-11-28 14:46:15.143 Tunnel: No
  . 2016-11-28 14:46:15.143 Transfer Protocol: SCP
  . 2016-11-28 14:46:15.143 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec
  . 2016-11-28 14:46:15.143 Disable Nagle: No
  . 2016-11-28 14:46:15.143 Proxy: None
  . 2016-11-28 14:46:15.143 Send buffer: 262144
  . 2016-11-28 14:46:15.143 SSH protocol version: 2; Compression: No
  . 2016-11-28 14:46:15.143 Bypass authentication: No
  . 2016-11-28 14:46:15.143 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: Yes
  . 2016-11-28 14:46:15.143 GSSAPI: Forwarding: No
  . 2016-11-28 14:46:15.143 Ciphers: aes,blowfish,3des,chacha20,WARN,arcfour,des; Ssh2DES: No
  . 2016-11-28 14:46:15.143 KEX: ecdh,dh-gex-sha1,dh-group14-sha1,dh-group1-sha1,rsa,WARN
  . 2016-11-28 14:46:15.143 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto
  . 2016-11-28 14:46:15.143 Simple channel: Yes
  . 2016-11-28 14:46:15.143 Return code variable: Autodetect; Lookup user groups: Auto
  . 2016-11-28 14:46:15.143 Shell: default
  . 2016-11-28 14:46:15.143 EOL: LF, UTF: Auto
  . 2016-11-28 14:46:15.143 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No
  . 2016-11-28 14:46:15.143 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
  . 2016-11-28 14:46:15.143 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
  . 2016-11-28 14:46:15.143 Cache directory changes: Yes, Permanent: Yes
  . 2016-11-28 14:46:15.143 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
  . 2016-11-28 14:46:15.143 DST mode: Unix;Timezone offset: 0h 0m
  . 2016-11-28 14:46:15.143 --------------------------------------------------------------------------
  . 2016-11-28 14:46:15.144 Looking up host "xxx.xx.xxx.229" for SSH connection
  . 2016-11-28 14:46:15.144 Connecting to xxx.xx.xxx.229 port 22
  . 2016-11-28 14:46:15.209 We claim version: SSH-2.0-WinSCP_release_5.9.2
  . 2016-11-28 14:46:15.531 Server version: SSH-2.0-dropbear_0.52
  . 2016-11-28 14:46:15.531 We believe remote version has SSH-2 channel request bug
  . 2016-11-28 14:46:15.531 Using SSH protocol version 2
  . 2016-11-28 14:46:15.531 Have a known host key of type rsa2
  . 2016-11-28 14:46:15.600 Using Diffie-Hellman with standard group "group1"
  . 2016-11-28 14:46:15.600 Doing Diffie-Hellman key exchange with hash SHA-1
  . 2016-11-28 14:46:18.528 Host key fingerprint is:
  . 2016-11-28 14:46:18.528 ssh-rsa 1040 ef:aa:a1:30:79:12:c7:f8:02:36:d0:ac:71:6b:5b:24
  . 2016-11-28 14:46:18.528 Verifying host key rsa2 0x10001,0x8655eaba5dcb7994 985cb3d6ebeca273 368ca5dce0996f2a 215340bc46dadc4e 707e0570ae0a9475 99998dbf78b0f313 0267082a5e2b7c92 0edb8494ca9d6b0c 95af8f39f05b2333 cd2dc78fb5787fef 219226c936158e39 fb408056a575d022 c024a55b92bcdb4b 09c3d638a1bc46ba f6912c03c78603fd c034dc7e0b20beda b967 with fingerprint ssh-rsa 1040 ef:aa:a1:30:79:12:c7:f8:02:36:d0:ac:71:6b:5b:24
  . 2016-11-28 14:46:18.529 Host key matches configured key
  . 2016-11-28 14:46:18.529 Initialised AES-256 SDCTR client-&gt;server encryption
  . 2016-11-28 14:46:18.529 Initialised HMAC-SHA1 client-&gt;server MAC algorithm
  . 2016-11-28 14:46:18.593 Initialised AES-256 SDCTR server-&gt;client encryption
  . 2016-11-28 14:46:18.593 Initialised HMAC-SHA1 server-&gt;client MAC algorithm
  ! 2016-11-28 14:46:18.661 Using username "root".
  . 2016-11-28 14:46:18.730 Server offered these authentication methods: publickey,password
  . 2016-11-28 14:46:18.730 Prompt (password, "SSH password", &lt;no instructions&gt;, "&amp;Password: ")
  . 2016-11-28 14:46:18.730 Using stored password.
  . 2016-11-28 14:46:18.731 Sent password
  . 2016-11-28 14:46:18.954 Access granted
  . 2016-11-28 14:46:18.954 Opening session as main channel
  . 2016-11-28 14:46:19.025 Opened main channel
  . 2016-11-28 14:46:19.213 Started a shell/command
  . 2016-11-28 14:46:19.213 --------------------------------------------------------------------------
  . 2016-11-28 14:46:19.213 Using SCP protocol.
  . 2016-11-28 14:46:19.214 Doing startup conversation with host.
  . 2016-11-28 14:46:19.214 Skipping host startup message (if any).
  &gt; 2016-11-28 14:46:19.214 echo "WinSCP: this is end-of-file:0"
  &lt; 2016-11-28 14:46:19.286 WinSCP: this is end-of-file:0
  . 2016-11-28 14:46:19.287 Detecting variable containing return code of last command.
  . 2016-11-28 14:46:19.287 Trying "$status".
  &gt; 2016-11-28 14:46:19.287 echo "$status" ; echo "WinSCP: this is end-of-file:0"
  &lt; 2016-11-28 14:46:19.615 WinSCP: this is end-of-file:0
  . 2016-11-28 14:46:19.615 The response is not numerical exit code
  . 2016-11-28 14:46:19.615 Trying "$?".
  &gt; 2016-11-28 14:46:19.615 echo "$?" ; echo "WinSCP: this is end-of-file:0"
  &lt; 2016-11-28 14:46:19.687 0
  &lt; 2016-11-28 14:46:19.949 WinSCP: this is end-of-file:0
  . 2016-11-28 14:46:19.949 Return code variable "$?" selected.
  &gt; 2016-11-28 14:46:19.949 printenv LANG ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:20.036 sh: can't exec 'printenv': No such file or directory
  &lt; 2016-11-28 14:46:20.301 WinSCP: this is end-of-file:1
  . 2016-11-28 14:46:20.301 We will not use UTF-8
  . 2016-11-28 14:46:20.301 Clearing all aliases.
  &gt; 2016-11-28 14:46:20.301 unalias "ls" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:20.380 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:20.644 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:20.645 unalias "echo" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:20.720 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:20.987 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:20.987 unalias "pwd" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:21.064 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:21.330 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:21.330 unalias "cd" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:21.404 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:21.664 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:21.664 unalias "groups" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:21.741 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:22.007 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:22.008 unalias "scp" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:22.083 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:22.350 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:22.350 unalias "rm" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:22.425 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:22.684 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:22.684 unalias "mv" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:22.759 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:23.027 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:23.027 unalias "mkdir" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:23.102 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:23.370 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:23.370 unalias "chmod" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:23.444 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:23.704 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:23.704 unalias "chgrp" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:23.780 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:24.047 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:24.047 unalias "chown" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:24.125 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:24.390 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:24.390 unalias "unset" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:24.464 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:24.730 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:24.730 unalias "unalias" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:24.805 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:25.069 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:25.069 unalias "ln" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:25.144 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:25.409 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:25.409 unalias "cp" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:25.484 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:25.749 WinSCP: this is end-of-file:1
  &gt; 2016-11-28 14:46:25.749 unalias "printenv" ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:25.824 sh: can't exec 'unalias': No such file or directory
  &lt; 2016-11-28 14:46:26.090 WinSCP: this is end-of-file:1
  . 2016-11-28 14:46:26.090 Clearing national user variables.
  &gt; 2016-11-28 14:46:26.090 unset "LANG" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.173 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.173 unset "LANGUAGE" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.246 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.246 unset "LC_CTYPE" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.320 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.320 unset "LC_COLLATE" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.394 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.394 unset "LC_MONETARY" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.467 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.467 unset "LC_NUMERIC" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.540 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.540 unset "LC_TIME" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.615 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.615 unset "LC_MESSAGES" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.688 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.688 unset "LC_ALL" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.761 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:46:26.761 unset "HUMAN_BLOCKS" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:26.835 WinSCP: this is end-of-file:0
  . 2016-11-28 14:46:26.835 Looking up groups and users.
  &gt; 2016-11-28 14:46:26.835 groups ; echo "WinSCP: this is end-of-file:$?"
  ! 2016-11-28 14:46:26.915 sh: can't exec 'groups': No such file or directory
  &lt; 2016-11-28 14:46:27.174 WinSCP: this is end-of-file:1
  . 2016-11-28 14:46:27.174 Getting current directory name.
  &gt; 2016-11-28 14:46:27.174 pwd ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:27.247 /
  &lt; 2016-11-28 14:46:27.247 WinSCP: this is end-of-file:0
  . 2016-11-28 14:46:27.247 Startup conversation with host finished.
  &lt; 2016-11-28 14:46:27.247 Script: Active session: [1] root@xxx.xx.xxx.229
  &gt; 2016-11-28 14:46:27.940 Script: pwd
  &lt; 2016-11-28 14:46:27.940 Script: /
  &gt; 2016-11-28 14:46:27.999 Script: put  -nopermissions -preservetime -transfer="binary" -- "C:\Users\.......\Documents\My Received Files\AAA1504v1_1_7.run" "/var/tmp/*"
  . 2016-11-28 14:46:28.000 Copying 1 files/directories to remote directory "/var/tmp/"
  . 2016-11-28 14:46:28.000   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: Yes; Mask: *
  . 2016-11-28 14:46:28.000   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
  . 2016-11-28 14:46:28.000   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
  &gt; 2016-11-28 14:46:28.000 echo "WinSCP: this is begin-of-file" ; scp -r  -d -t "/var/tmp" ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:46:28.114 WinSCP: this is begin-of-file
  . 2016-11-28 14:46:28.374 SCP remote side confirmation (0)
  . 2016-11-28 14:46:28.374 File: "C:\Users\.......\Documents\My Received Files\AAA1504v1_1_7.run"
  . 2016-11-28 14:46:28.375 File: 'C:\Users\.......\Documents\My Received Files\AAA1504v1_1_7.run' [2016-11-22T18:08:47.884Z] [2449208]
  . 2016-11-28 14:46:28.381 Copying "C:\Users\.......\Documents\My Received Files\AAA1504v1_1_7.run" to remote directory started.
  . 2016-11-28 14:46:28.381 Binary transfer mode selected.
  &gt; 2016-11-28 14:46:28.382 T1479838127 0 1479838174 0
  . 2016-11-28 14:46:28.455 SCP remote side confirmation (0)
  &gt; 2016-11-28 14:46:28.455 C0644 2449208 AAA1504v1_1_7.run
  . 2016-11-28 14:46:28.531 SCP remote side confirmation (0)
  . 2016-11-28 14:46:28.531 Sending BINARY data (first block, 32768 bytes)
  . 2016-11-28 14:47:34.788 Sending NULL.
  . 2016-11-28 14:47:36.266 SCP remote side confirmation (0)
  . 2016-11-28 14:47:36.266 Transfer done: 'C:\Users\.......\Documents\My Received Files\AAA1504v1_1_7.run' [2449208]
  . 2016-11-28 14:47:36.266 Copying "C:\Users\.......\Documents\My Received Files\AAA1504v1_1_7.run" to remote directory finished.
  &gt; 2016-11-28 14:47:36.267 E
  . 2016-11-28 14:47:36.341 SCP remote side confirmation (0)
  &lt; 2016-11-28 14:47:36.341 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:47:36.789 Script: call cd /tmp
  . 2016-11-28 14:47:36.789 Executing user defined command.
  &gt; 2016-11-28 14:47:36.789 cd /tmp ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:47:36.865 WinSCP: this is end-of-file:0
  . 2016-11-28 14:47:36.865 Getting current directory name.
  &gt; 2016-11-28 14:47:36.865 pwd ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:47:36.938 /var/tmp
  &lt; 2016-11-28 14:47:36.938 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:47:36.966 Script: call chmod 777 *.run
  . 2016-11-28 14:47:36.966 Executing user defined command.
  &gt; 2016-11-28 14:47:36.966 chmod 777 *.run ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:47:37.115 WinSCP: this is end-of-file:0
  . 2016-11-28 14:47:37.115 Getting current directory name.
  &gt; 2016-11-28 14:47:37.116 pwd ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:47:37.189 /var/tmp
  &lt; 2016-11-28 14:47:37.189 WinSCP: this is end-of-file:0
  &gt; 2016-11-28 14:47:37.369 Script: call ./AAA1504v1_1_7.run --load
  . 2016-11-28 14:47:37.369 Executing user defined command.
  &gt; 2016-11-28 14:47:37.369 ./AAA1504v1_1_7.run --load ; echo "WinSCP: this is end-of-file:$?"
  &lt; 2016-11-28 14:47:42.682 Script: Searching for firmware
  &lt; 2016-11-28 14:47:42.683 Searching for firmware
  &lt; 2016-11-28 14:47:42.683 Script: Validating firmware
  &lt; 2016-11-28 14:47:42.683 Validating firmware
  &lt; 2016-11-28 14:47:42.683 Script: Image:
  &lt; 2016-11-28 14:47:42.683 Image:
  &lt; 2016-11-28 14:47:42.683 Script:  Image version :1
  &lt; 2016-11-28 14:47:42.683  Image version :1
  &lt; 2016-11-28 14:47:42.683 Script:  Product       :AAA 1504
  &lt; 2016-11-28 14:47:42.684  Product       :AAA 1504
  &lt; 2016-11-28 14:47:42.684 Script:  Version       :1.1.7
  &lt; 2016-11-28 14:47:42.684  Version       :1.1.7
  &lt; 2016-11-28 14:47:42.684 Script: AAA image:
  &lt; 2016-11-28 14:47:42.684 AAA image:
  &lt; 2016-11-28 14:47:42.684 Script:  Version  :1.1.7
  &lt; 2016-11-28 14:47:42.684  Version  :1.1.7
  &lt; 2016-11-28 14:47:42.684 Script:  Checksum :0x6386
  &lt; 2016-11-28 14:47:42.685  Checksum :0x6386
  &lt; 2016-11-28 14:47:42.685 Script:  Length   :100329
  &lt; 2016-11-28 14:47:42.688  Length   :100329
  &lt; 2016-11-28 14:47:42.688 Script:  date     :Tue May 17 13:49:54 2016
  &lt; 2016-11-28 14:47:42.688  date     :Tue May 17 13:49:54 2016
  &lt; 2016-11-28 14:47:42.688 Script:  name     :'AAA1504v117.bin'
  &lt; 2016-11-28 14:47:42.689  name     :'AAA1504v117.bin'
  &lt; 2016-11-28 14:47:42.689 Script: MPD image:
  &lt; 2016-11-28 14:47:42.689 MPD image:
  &lt; 2016-11-28 14:47:49.192 Script:  Version  :1.1.9
  &lt; 2016-11-28 14:47:49.193  Version  :1.1.9
  &lt; 2016-11-28 14:47:49.193 Script:  Checksum :0x8D29
  &lt; 2016-11-28 14:47:49.193  Checksum :0x8D29
  &lt; 2016-11-28 14:47:49.193 Script:  Length   :2295808
  &lt; 2016-11-28 14:47:49.194  Length   :2295808
  &lt; 2016-11-28 14:47:49.194 Script: A393B7ED1E98D478D3DC7A567EAD7A0E valid
  &lt; 2016-11-28 14:47:49.195 A393B7ED1E98D478D3DC7A567EAD7A0E valid
  &lt; 2016-11-28 14:47:49.195 Script: Valid firmware
  &lt; 2016-11-28 14:47:49.195 Valid firmware
  &lt; 2016-11-28 14:48:07.559 Script: Updating AAA.........success
  &lt; 2016-11-28 14:48:07.559 Updating AAA.........success
  . 2016-11-28 14:48:46.496 Waiting for data timed out, asking user what to do.
  . 2016-11-28 14:48:46.496 Asking user:
  . 2016-11-28 14:48:46.496 **Host is not communicating for 15 seconds.
  . 2016-11-28 14:48:46.496 
  . 2016-11-28 14:48:46.496 Wait for another 15 seconds?** ()
  &lt; 2016-11-28 14:48:46.496 Script: Host is not communicating for more than 15 seconds.
  &lt; 2016-11-28 14:48:46.496 Still waiting...
  &lt; 2016-11-28 14:48:46.496 Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
  &lt; 2016-11-28 14:48:46.496 Warning: Aborting this operation will close connection!
  . 2016-11-28 14:49:46.029 Attempt to close connection due to fatal exception:
  * 2016-11-28 14:49:46.029 **Terminated by user.**
  . 2016-11-28 14:49:46.029 Closing connection.
  . 2016-11-28 14:49:46.029 Sending special code: 12
  . 2016-11-28 14:49:46.030 Sent EOF message
  &lt; 2016-11-28 14:49:46.030 Script: Terminated by user.
  </code></pre>