Batch file runs when manually typed but, not when executed
I have a batch file that needs to pull down some files from another site, copy them to a few places and then upload them to a couple of sites. I wrote everything and pasted it in the command prompt and it seemed like it was going to be perfect. Each segment did what it was supposed to do but, when I launch it, it hangs after my first sftp connection.
The script is hanging after I make the connection. All that I see in the command prompt is:
Here is my log file:
Any ideas on this one? Should I just break every segment into a different batch file and call it in a main batch file?
Anything that anyone has on this would be greatly appreciated. I am 6 hours into this and am finally asking for help.
Thanks!
echo on set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2% echo %curr_date% cd\scripts winscp /console /log=c:\temp\sender.log /command "open sftp://user:password@sshftp.sender.com:22" cd /Download lcd c:\receiver\PROD\sender get -delete sender1*.* get -delete sender2*.* exit c: cd\receiver\PROD\sender copy sender1*.* "H:\shared directory1" copy sender2*.* "H:\shared directory2"
Searching for host... Connecting to host... Authenticating... Using username "user". Authenticating with pre-entered password. Authenticated. Starting the session... Session started. Active session: [1] user@sshftp.sender.com winscp>
. 2021-06-15 15:11:17.622 -------------------------------------------------------------------------- . 2021-06-15 15:11:17.622 WinSCP Version 5.9.3 (Build 7136) (OS 10.0.18363 - Windows 10 Enterprise) . 2021-06-15 15:11:17.622 Configuration: C:\Scripts\WinSCP.ini . 2021-06-15 15:11:17.622 Log level: Normal . 2021-06-15 15:11:17.622 Local account: domain\username . 2021-06-15 15:11:17.622 Working directory: C:\Scripts . 2021-06-15 15:11:17.622 Process ID: 24432 . 2021-06-15 15:11:17.622 Command-line: "C:\Scripts\WinSCP.exe" /console=593 /consoleinstance=_19828_799 "/console" "/log=c:\temp\sender.log" "/command" "open sftp://user:***@sshftp.sender.com:22" . 2021-06-15 15:11:17.622 Time zone: Current: GMT-4, Standard: GMT-5 (Eastern Standard Time), DST: GMT-4 (Eastern Daylight Time), DST Start: 3/14/2021, DST End: 11/7/2021 . 2021-06-15 15:11:17.622 Login time: Tuesday, June 15, 2021 3:11:17 PM . 2021-06-15 15:11:17.622 -------------------------------------------------------------------------- . 2021-06-15 15:11:17.622 Script: Retrospectively logging previous script records: > 2021-06-15 15:11:17.622 Script: open sftp://user:***@sshftp.sender.com:22/ . 2021-06-15 15:11:17.622 -------------------------------------------------------------------------- . 2021-06-15 15:11:17.622 Session name: user@sshftp.sender.com (Ad-Hoc site) . 2021-06-15 15:11:17.622 Host name: sshftp.sender.com (Port: 22) . 2021-06-15 15:11:17.622 User name: user (Password: Yes, Key file: No, Passphrase: No) . 2021-06-15 15:11:17.622 Tunnel: No . 2021-06-15 15:11:17.622 Transfer Protocol: SFTP . 2021-06-15 15:11:17.622 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec . 2021-06-15 15:11:17.622 Disable Nagle: No . 2021-06-15 15:11:17.622 Proxy: None . 2021-06-15 15:11:17.622 Send buffer: 262144 . 2021-06-15 15:11:17.622 SSH protocol version: 2; Compression: No . 2021-06-15 15:11:17.622 Bypass authentication: No . 2021-06-15 15:11:17.622 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No . 2021-06-15 15:11:17.622 Ciphers: aes,chacha20,blowfish,3des,WARN,arcfour,des; Ssh2DES: No . 2021-06-15 15:11:17.622 KEX: ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN,dh-group1-sha1 . 2021-06-15 15:11:17.622 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto . 2021-06-15 15:11:17.622 Simple channel: Yes . 2021-06-15 15:11:17.622 Return code variable: Autodetect; Lookup user groups: Auto . 2021-06-15 15:11:17.622 Shell: default . 2021-06-15 15:11:17.622 EOL: LF, UTF: Auto . 2021-06-15 15:11:17.622 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No . 2021-06-15 15:11:17.622 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No . 2021-06-15 15:11:17.622 SFTP Bugs: Auto,Auto . 2021-06-15 15:11:17.622 SFTP Server: default . 2021-06-15 15:11:17.622 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes . 2021-06-15 15:11:17.622 Cache directory changes: Yes, Permanent: Yes . 2021-06-15 15:11:17.622 Recycle bin: Delete to: No, Overwritten to: No, Bin path: . 2021-06-15 15:11:17.622 DST mode: Unix . 2021-06-15 15:11:17.622 -------------------------------------------------------------------------- . 2021-06-15 15:11:17.622 Looking up host "sshftp.sender.com" for SSH connection . 2021-06-15 15:11:17.654 Connecting to X.X.X.X port 22 . 2021-06-15 15:11:17.669 We claim version: SSH-2.0-WinSCP_release_5.9.3 . 2021-06-15 15:11:17.685 Server version: SSH-2.0-7.9.0.0_openssh Globalscape . 2021-06-15 15:11:17.685 We believe remote version has SSH-2 channel request bug . 2021-06-15 15:11:17.685 Using SSH protocol version 2 . 2021-06-15 15:11:17.685 Have a known host key of type rsa2 . 2021-06-15 15:11:17.716 Doing Diffie-Hellman group exchange . 2021-06-15 15:11:17.795 Doing Diffie-Hellman key exchange with hash SHA-256 . 2021-06-15 15:11:20.310 Host key fingerprint is: . 2021-06-15 15:11:20.310 ssh-rsa 2048 blah blah blah . 2021-06-15 15:11:20.310 Verifying host key blah blah blah . 2021-06-15 15:11:20.310 Host key matches cached key . 2021-06-15 15:11:20.310 Initialised AES-256 SDCTR client->server encryption . 2021-06-15 15:11:20.310 Initialised HMAC-SHA-256 client->server MAC algorithm . 2021-06-15 15:11:20.310 Initialised AES-256 SDCTR server->client encryption . 2021-06-15 15:11:20.310 Initialised HMAC-SHA-256 server->client MAC algorithm ! 2021-06-15 15:11:20.388 Using username "user". . 2021-06-15 15:11:20.419 Server offered these authentication methods: password,keyboard-interactive . 2021-06-15 15:11:20.419 Attempting keyboard-interactive authentication . 2021-06-15 15:11:20.435 Prompt (keyboard interactive, "SSH server authentication", "Using keyboard-interactive authentication.", "Enter password: ") . 2021-06-15 15:11:20.435 Using stored password. . 2021-06-15 15:11:20.466 Access granted . 2021-06-15 15:11:20.466 Opening session as main channel . 2021-06-15 15:11:20.482 Opened main channel . 2021-06-15 15:11:20.560 Started a shell/command . 2021-06-15 15:11:20.560 -------------------------------------------------------------------------- . 2021-06-15 15:11:20.576 Using SFTP protocol. . 2021-06-15 15:11:20.576 Doing startup conversation with host. > 2021-06-15 15:11:20.576 Type: SSH_FXP_INIT, Size: 5, Number: -1 < 2021-06-15 15:11:20.591 Type: SSH_FXP_VERSION, Size: 5, Number: -1 . 2021-06-15 15:11:20.591 SFTP version 3 negotiated. . 2021-06-15 15:11:20.591 We believe the server has signed timestamps bug . 2021-06-15 15:11:20.591 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 strings are not mandatory . 2021-06-15 15:11:20.591 Getting current directory name. . 2021-06-15 15:11:20.591 Getting real path for '.' > 2021-06-15 15:11:20.591 Type: SSH_FXP_REALPATH, Size: 10, Number: 16 < 2021-06-15 15:11:20.607 Type: SSH_FXP_NAME, Size: 23, Number: 16 . 2021-06-15 15:11:20.607 Real path is '/' . 2021-06-15 15:11:20.607 Startup conversation with host finished. < 2021-06-15 15:11:20.607 Script: Active session: [1] user@sshftp.sender.com
Anything that anyone has on this would be greatly appreciated. I am 6 hours into this and am finally asking for help.
Thanks!