Passing a password to su

Hi

I am running unix commands through Oracle, but I want to be able to run sftp which oracle cannot use. What I want to do is run a script which runs as oracle user but has the su command in, to connect as another user that has sftp access. I am trying the below.

su - dwintuser -c gary.ksh <<EOF
`echo $passwd`
EOF

This does not work as I can't seem to be able to pass a password to su. Is there a way round this or another option for running sftp as an oracle user without the oracle user having access to the ftp server.

Cheers
Gary

using Expect might help you

Something like :

spawn sftp -o Port=$port $user@$host
expect assword:

send "$pass\r"
expect sftp>

send "$cmd $from_file $to_file\r"
expect sftp>

send "exit\r"
expect eof

where you should replace all the respective variables.