sftp failed to recognize commands in a batch file

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
pnguyen2020
Posts: 3
Joined: Tue Jun 16, 2020 7:42 am

sftp failed to recognize commands in a batch file

Post by pnguyen2020 »

I run sftp -b batch_file.txt myid@myserver.com in a Window powershell or cmd but it responded with a 'invalid command'. The batch_file.txt contains just ls and pwd. These are legal commands. It appears sftp only read the first character and interpreted that as the command since the error message says 'l invalid command'. If I run sftp -b - myid@myserver.com, which means getting input from stdin, then it can understand commands that I typed
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: sftp failed to recognize commands in a batch file

Post by dovetail »

I'm not sure what the problem here is, but as described there seems to be something wrong with how you are using the Windows sftp client.

- Does it work with -b batch mode to another ssh/sftp server?
-- if not, then I suggest that you check with powershell openssh support areas
pnguyen2020
Posts: 3
Joined: Tue Jun 16, 2020 7:42 am

Re: sftp failed to recognize commands in a batch file

Post by pnguyen2020 »

I found the issue; it has to do with encoding (e.g. UTF-8). If the text is not created in UTF-8, server will reject it even though you have no clue why (i.e. can't see what is wrong with the text)
Post Reply