#! /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脚本实现文件上传的功能。问题:当用户名,密码,路径,写错时脚本不会中断,并返回错误信息。求大神指导!
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脚本实现文件上传的功能。问题:当用户名,密码,路径,写错时脚本不会中断,并返回错误信息。求大神指导!
解决方案 »
- window linux 系统集成咨询
- ubuntu安装xen,make install一直提示:Missing file: arch/x86/boot/vmlinuz
- XShell5 rz上传文件出现乱码
- linux 大神,请否帮我解决一下这个问题
- linux system函数调用shell 命令出错解决方法?
- 关于poll IO复用求助大神
- 购买的阿里云服务器装mysql 一直启动不了
- Linux部署fastdfs实现图片上传,图片上传成功但是访问失败 求解答!
- Debian6经常不定期死机,日志里出现网卡异常
- shell参数的问题
- ubuntu安装xen,make install一直提示:Missing file: arch/x86/boot/vmlinuz
- postfix 465端口问题
expect {
"aaaa" {send "\r"}
default {send_error "expect_timeout 2"; exit 1}
}
expect eof
exit 0
使用 exit [val] 看看