Can upload file in GUI but not via script

Advertisement

infrachief
Joined:
Posts:
3
Location:
U.S.

Can upload file in GUI but not via script

I am able to upload a document to FTP server via WinSCP GUI, with warnings, however I cannot do this via simple script
open sftp:
put * -nopermissions
exit
In log I can see that the username and password is accepted fine however the same credentials that work in GUI do not work via script.
< 2023-11-21 15:57:32.681 Script: Authenticating with pre-entered password.
. 2023-11-21 15:57:32.681 Sent password
. 2023-11-21 15:57:34.477 Access granted
. 2023-11-21 15:57:34.477 Opening main session channel
. 2023-11-21 15:57:34.508 Opened main channel
. 2023-11-21 15:57:34.508 Started a shell/command
< 2023-11-21 15:57:34.508 Script: Authenticated.
. 2023-11-21 15:57:34.508 --------------------------------------------------------------------------
. 2023-11-21 15:57:34.508 Using SFTP protocol.
. 2023-11-21 15:57:34.508 Doing startup conversation with host.
< 2023-11-21 15:57:34.508 Script: Starting the session...
> 2023-11-21 15:57:34.508 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2023-11-21 15:57:36.512 Type: SSH_FXP_VERSION, Size: 5, Number: -1
 
. 2023-11-21 15:57:36.539 Binary transfer mode selected.
. 2023-11-21 15:57:36.539 Checking existence of file.
> 2023-11-21 15:57:36.539 Type: SSH_FXP_LSTAT, Size: 43, Number: 775
< 2023-11-21 15:57:37.116 Type: SSH_FXP_STATUS, Size: 38, Number: 775
< 2023-11-21 15:57:37.116 Status code: 3, Message: 775, Server: Access denied, Language: US-ASCII 
. 2023-11-21 15:57:37.116 Checking existence of partially transferred file.
> 2023-11-21 15:57:37.116 Type: SSH_FXP_LSTAT, Size: 52, Number: 1031
< 2023-11-21 15:57:37.210 Type: SSH_FXP_STATUS, Size: 38, Number: 1031
< 2023-11-21 15:57:37.210 Status code: 3, Message: 1031, Server: Access denied, Language: US-ASCII 
. 2023-11-21 15:57:37.210 Opening remote file.
> 2023-11-21 15:57:37.210 Type: SSH_FXP_OPEN, Size: 68, Number: 1283
< 2023-11-21 15:57:37.290 Type: SSH_FXP_STATUS, Size: 38, Number: 1283
< 2023-11-21 15:57:37.290 Status code: 3, Message: 1283, Server: Access denied, Language: US-ASCII 
> 2023-11-21 15:57:37.290 Type: SSH_FXP_LSTAT, Size: 52, Number: 1543
< 2023-11-21 15:57:37.368 Type: SSH_FXP_STATUS, Size: 38, Number: 1543
< 2023-11-21 15:57:37.368 Status code: 3, Message: 1543, Server: Access denied, Language: US-ASCII 
* 2023-11-21 15:57:37.368 (ETerminal) Permission denied.
* 2023-11-21 15:57:37.368 Error code: 3
* 2023-11-21 15:57:37.368 Error message from server (US-ASCII): Access denied
. 2023-11-21 15:57:37.368 Asking user:
. 2023-11-21 15:57:37.368 Cannot create remote file '/.csv.filepart'. ("Permission denied.
. 2023-11-21 15:57:37.368 Error code: 3
. 2023-11-21 15:57:37.368 Error message from server (US-ASCII): Access denied")
< 2023-11-21 15:57:37.368 Script: Cannot create remote file '/.csv.filepart'.
< 2023-11-21 15:57:37.368 Script: Permission denied.
< 2023-11-21 15:57:37.368 Error code: 3
< 2023-11-21 15:57:37.368 Error message from server (US-ASCII): Access denied
. 2023-11-21 15:57:37.368 Answer: Abort
* 2023-11-21 15:57:37.368 (ESkipFile) Cannot create remote file '/.csv.filepart'.
* 2023-11-21 15:57:37.368 Permission denied.
* 2023-11-21 15:57:37.368 Error code: 3
* 2023-11-21 15:57:37.368 Error message from server (US-ASCII): Access denied
. 2023-11-21 15:57:37.368 Copying finished: Transferred: 0, Elapsed: 0:00:00, CPS: 0/s
. 2023-11-21 15:57:37.368 Script: Failed
. 2023-11-21 15:57:37.368 Script: Exit code: 1
. 2023-11-21 15:57:37.368 Closing connection.
. 2023-11-21 15:57:37.368 Sending special code: 1
. 2023-11-21 15:57:37.826 Session sent command exit status 0
. 2023-11-21 15:57:37.826 Main session channel closed
. 2023-11-21 15:57:37.826 All channels closed
I found this stack overflow post but I'm confident my account has access to create files, otherwise I wouldn't be able to do it via GUI, dragging a file into the FTP server folder.
WinSCP: Permission denied. Error code: 3 Error message from server: Permission denied
Running Version 6.1.2 (Build 13797 2023-09-19)
Anyone else run across similar issues?

winscp upload via GUI with warnings.png

winscp upload via GUI with warnings.png

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,392
Location:
Prague, Czechia

You are connecting to a different host (IP) in script and GUI.

Also, in GUI you are uploading to /sftpgateway-i-04f566964c5b7ff21/greenthumbindustries/uploads/.
While in script, you are uploading to /uploads.

Reply with quote

infrachief
Joined:
Posts:
3
Location:
U.S.

Thanks Martin! The connection commands were generated from GUI so that wasn't the issue, the remote directory/folder was. I didn't realize FTP server directed me into a series of subfolders, upon login, via GUI method. The upload is working, with errors, after changing directory to match.

Remaining question is about the set stat errors, see below. In my script I'm using put * -nopermissions. Is there a proper put switch option I should be using to ignore permission and stop SETSTAT from being attempted in the first place?
. 2023-11-30 11:22:30.978 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option. ("The server does not support the operation.
. 2023-11-30 11:22:30.978 Error code: 8
. 2023-11-30 11:22:30.978 Error message from server (US-ASCII): SETSTAT unsupported")
< 2023-11-30 11:22:30.978 Script: Upload of file 'REDACTED.csv' was successful, but error occurred while setting the permissions and/or timestamp.
< 2023-11-30 11:22:30.978 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
< 2023-11-30 11:22:30.978 Script: The server does not support the operation.
< 2023-11-30 11:22:30.978 Error code: 8
< 2023-11-30 11:22:30.978 Error message from server (US-ASCII): SETSTAT unsupported
. 2023-11-30 11:22:30.978 Answer: Abort
* 2023-11-30 11:22:30.978 (ESkipFile) **Upload of file 'REDACTED.csv' was successful, but error occurred while setting the permissions and/or timestamp.**
* 2023-11-30 11:22:30.978 
* 2023-11-30 11:22:30.978 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
* 2023-11-30 11:22:30.978 The server does not support the operation.
* 2023-11-30 11:22:30.978 Error code: 8
* 2023-11-30 11:22:30.978 Error message from server (US-ASCII): SETSTAT unsupported
. 2023-11-30 11:22:30.978 Copying finished: Transferred: 261,084, Elapsed: 0:00:02, CPS: 122,863/s

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,392
Location:
Prague, Czechia

The -nopermissions is default, so it's typically not necessary. But you need -nopreservetime.
https://winscp.net/eng/docs/scriptcommand_put#nopreservetime

See Upload of file .. was successful, but error occurred while setting the permissions and/or timestamp. If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on ‘Ignore permission errors’ option.

Reply with quote

Advertisement

You can post new topics in this forum