SFTP error

Hello Guys,

i am trying to connect to one server using SFTP, but i am getting the below error message.

 
tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Not a typewriter
 
error: Connection lost
echo "Starting SFTP"
USERNAME=abc
PASSWORD=765a
echo "
ascii
put test.dat
bye" | sftp --password=$PASSWORD USERNAME@test.server.com#2200 > sftp.error 2>&1
 

i am using HP-UX OS. i am able to do this from the command line. i am having issues only when i try to run from shell script. Please help me on this. Thanks

Seems that sftp wants a terminal for stdout. Does your sftp client have -b (batch) option? Maybe that will work and allow you capture stdout?

---------- Post updated at 10:55 AM ---------- Previous update was at 10:50 AM ----------

Most sftp programs don't have a --password option and expect you to use ssh keys and go passwordless for a 'batch' operation (just saying). In which case you might even be able to use scp instead of sftp.

No. i tried using -B option as well. but i am getting the error "could not read the batch file, file: --password=765a". Please advise

 
sftp -B --password=$PASSWORD USERNAME@test.server.com#2200 > sftp.error 2>&1

You will need to expand USERNAME with $ .