I have made the sftp password less using the ssh -t key_gen option and the prompt for password does not appear anymore but when I write the commands to be executed on the sftp session like the following in the shell script and execute it they are not executed instead i just get the prompt of sftp
#!/bin/sh
username=$1
ipaddr=$2
external_path=$3
extension=$4
sftp $username@$ipaddr
cd $external_path
get *.$extension
exit
Result
sftp>
and nothing else
Could you please tell how this can be achieved, also the expect utility is there on my machine but the sftp does not support the -b option
Thanks,
Priyanka
Best Answer
sftp username@ipaddress will have sftp enter interactive mode. (Thats why you get an sftp style prompt)
sftp man page
Since you are using sftp programmability, you want to use it in non interactive mode.