#! /bin/sh
ftpIp=$1
ftpUser=$2
ftpPwd=$3
ftpPort=$4
ftpRemotePath=$5
fileName=$6
localPath=$7
expect <<!
spawn sftp $ftpUser@$ftpIp
expect "$ftpUser@$ftpIp's password:"
#发送密码
send "$ftpPwd"
send "\r"
expect "sftp>"
#设定lcd,cd
send "lcd $localPath\r"
send "cd $ftpRemotePath\r"
expect "sftp>"
#上传文件
send "put $fileName  $fileName\r"
expect "sftp>"
send "bye\r"
interact
expect eof
!
======================================
java调用shell脚本实现文件上传的功能。问题:当用户名,密码,路径,写错时脚本不会中断,并返回错误信息。求大神指导!