SFTP script not completing
Hello All -
I am running into problems fully executing the script below. I run the script it opens winscp and logs in fine. I see the remote directory. I am trying to change the local directory to C:\Needles\Podium but it will not change and the local dir stays at C:\. What do I need to do to have the script change the local dir to C:\Needles\Podium and upload any files that end in csv? I have tried using lcd C:\Needles\Podium and that does not work either. Below is the ending of the logfile and .ps script.
LogFile
. 2018-11-29 11:51:54.312 Server offered these authentication methods: publickey,password
. 2018-11-29 11:51:54.312 Prompt (password, "SSH password", <no instructions>, "&Password: ")
. 2018-11-29 11:51:54.312 Using stored password.
. 2018-11-29 11:51:54.328 Sent password
. 2018-11-29 11:51:54.437 Access granted
. 2018-11-29 11:51:54.437 Opening session as main channel
. 2018-11-29 11:51:54.968 Opened main channel
. 2018-11-29 11:51:55.156 Started a shell/command
. 2018-11-29 11:51:55.203 --------------------------------------------------------------------------
. 2018-11-29 11:51:55.203 Using SFTP protocol.
. 2018-11-29 11:51:55.203 Doing startup conversation with host.
> 2018-11-29 11:51:55.218 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2018-11-29 11:51:55.296 Type: SSH_FXP_VERSION, Size: 150, Number: -1
. 2018-11-29 11:51:55.296 SFTP version 3 negotiated.
. 2018-11-29 11:51:55.296 Unknown server extension posix-rename@openssh.com="1"
. 2018-11-29 11:51:55.296 Supports statvfs@openssh.com extension version "2"
. 2018-11-29 11:51:55.312 Unknown server extension fstatvfs@openssh.com="2"
. 2018-11-29 11:51:55.312 Supports hardlink@openssh.com extension version "1"
. 2018-11-29 11:51:55.312 Unknown server extension fsync@openssh.com="1"
. 2018-11-29 11:51:55.312 We believe the server has signed timestamps bug
. 2018-11-29 11:51:55.312 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
. 2018-11-29 11:51:55.312 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2018-11-29 11:51:55.312 Getting current directory name.
. 2018-11-29 11:51:55.312 Getting real path for '.'
> 2018-11-29 11:51:55.312 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2018-11-29 11:51:55.390 Type: SSH_FXP_NAME, Size: 39, Number: 16
. 2018-11-29 11:51:55.390 Real path is '/uploader'
. 2018-11-29 11:51:55.453 Listing directory "/uploader".
> 2018-11-29 11:51:55.453 Type: SSH_FXP_OPENDIR, Size: 18, Number: 267
< 2018-11-29 11:51:55.531 Type: SSH_FXP_HANDLE, Size: 13, Number: 267
> 2018-11-29 11:51:55.531 Type: SSH_FXP_READDIR, Size: 13, Number: 524
< 2018-11-29 11:51:55.624 Type: SSH_FXP_NAME, Size: 207, Number: 524
> 2018-11-29 11:51:55.624 Type: SSH_FXP_READDIR, Size: 13, Number: 780
< 2018-11-29 11:51:55.718 Type: SSH_FXP_STATUS, Size: 28, Number: 780
< 2018-11-29 11:51:55.718 Status code: 1
> 2018-11-29 11:51:55.718 Type: SSH_FXP_CLOSE, Size: 13, Number: 1028
. 2018-11-29 11:51:55.718 ..;d;0;2018-10-25T19:02:04.000Z;3;"0" [0];"516" [516];rwxr-xr-x;0
. 2018-11-29 11:51:55.781 Startup conversation with host finished.
Script
# Connect to SFTP ADDED two extra ^^ to allow the entry of the special character in the password
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log=logfile.log sftp://USER:PASSWORDe@FTPSERVER
# Change local directory to file location
localchdir ("C:\Needles\Podium")
# Upload files to Podium
put C:\Needles\Podium\NeedlesPodiumExport.csv
# Disconnect
close
# Exit WinSCP
exit
I am running into problems fully executing the script below. I run the script it opens winscp and logs in fine. I see the remote directory. I am trying to change the local directory to C:\Needles\Podium but it will not change and the local dir stays at C:\. What do I need to do to have the script change the local dir to C:\Needles\Podium and upload any files that end in csv? I have tried using lcd C:\Needles\Podium and that does not work either. Below is the ending of the logfile and .ps script.
LogFile
. 2018-11-29 11:51:54.312 Server offered these authentication methods: publickey,password
. 2018-11-29 11:51:54.312 Prompt (password, "SSH password", <no instructions>, "&Password: ")
. 2018-11-29 11:51:54.312 Using stored password.
. 2018-11-29 11:51:54.328 Sent password
. 2018-11-29 11:51:54.437 Access granted
. 2018-11-29 11:51:54.437 Opening session as main channel
. 2018-11-29 11:51:54.968 Opened main channel
. 2018-11-29 11:51:55.156 Started a shell/command
. 2018-11-29 11:51:55.203 --------------------------------------------------------------------------
. 2018-11-29 11:51:55.203 Using SFTP protocol.
. 2018-11-29 11:51:55.203 Doing startup conversation with host.
> 2018-11-29 11:51:55.218 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2018-11-29 11:51:55.296 Type: SSH_FXP_VERSION, Size: 150, Number: -1
. 2018-11-29 11:51:55.296 SFTP version 3 negotiated.
. 2018-11-29 11:51:55.296 Unknown server extension posix-rename@openssh.com="1"
. 2018-11-29 11:51:55.296 Supports statvfs@openssh.com extension version "2"
. 2018-11-29 11:51:55.312 Unknown server extension fstatvfs@openssh.com="2"
. 2018-11-29 11:51:55.312 Supports hardlink@openssh.com extension version "1"
. 2018-11-29 11:51:55.312 Unknown server extension fsync@openssh.com="1"
. 2018-11-29 11:51:55.312 We believe the server has signed timestamps bug
. 2018-11-29 11:51:55.312 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
. 2018-11-29 11:51:55.312 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2018-11-29 11:51:55.312 Getting current directory name.
. 2018-11-29 11:51:55.312 Getting real path for '.'
> 2018-11-29 11:51:55.312 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2018-11-29 11:51:55.390 Type: SSH_FXP_NAME, Size: 39, Number: 16
. 2018-11-29 11:51:55.390 Real path is '/uploader'
. 2018-11-29 11:51:55.453 Listing directory "/uploader".
> 2018-11-29 11:51:55.453 Type: SSH_FXP_OPENDIR, Size: 18, Number: 267
< 2018-11-29 11:51:55.531 Type: SSH_FXP_HANDLE, Size: 13, Number: 267
> 2018-11-29 11:51:55.531 Type: SSH_FXP_READDIR, Size: 13, Number: 524
< 2018-11-29 11:51:55.624 Type: SSH_FXP_NAME, Size: 207, Number: 524
> 2018-11-29 11:51:55.624 Type: SSH_FXP_READDIR, Size: 13, Number: 780
< 2018-11-29 11:51:55.718 Type: SSH_FXP_STATUS, Size: 28, Number: 780
< 2018-11-29 11:51:55.718 Status code: 1
> 2018-11-29 11:51:55.718 Type: SSH_FXP_CLOSE, Size: 13, Number: 1028
. 2018-11-29 11:51:55.718 ..;d;0;2018-10-25T19:02:04.000Z;3;"0" [0];"516" [516];rwxr-xr-x;0
. 2018-11-29 11:51:55.781 Startup conversation with host finished.
Script
# Connect to SFTP ADDED two extra ^^ to allow the entry of the special character in the password
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log=logfile.log sftp://USER:PASSWORDe@FTPSERVER
# Change local directory to file location
localchdir ("C:\Needles\Podium")
# Upload files to Podium
put C:\Needles\Podium\NeedlesPodiumExport.csv
# Disconnect
close
# Exit WinSCP
exit