用于自动执行 ftp 操作的 linux 脚本 [英] linux script to automate ftp operation

查看:17
本文介绍了用于自动执行 ftp 操作的 linux 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将文件从我的 linux 服务器传输到 FTP 服务器.

I need to transfer a file from my linux server to a FTP server.

我的 shell 脚本是:

My shell script is :

    #! /bin/ksh

    HOST='my_ip'
    USER='userid'
    PASSWD='password'
    FILE='file.txt'
    DIREC='/eir_log'
    ftp -in $HOST << EOMYF 
    user $USER $PASSWD
    binary
    mkdir $DIREC 
    cd $DIREC
    pwd
    quit
    EOMYF

相当简单的代码.但问题是虽然我可以很好地登录 FTP 服务器,但它不允许我在 FTP 服务器中创建新目录.起初我认为我的脚本有些错误,但即使我单独在 ftp 服务器中运行 mkdir,它也会显示 create directory failed.有人可以让我知道可能的错误,或者我的代码中是否有任何我遗漏的错误. pwd 工作正常,这意味着通过脚本登录 ftp 站点没有问题.

pretty simple code. but the problem is though I am logging in the FTP server fine, but its not allowing me to create a new directory in the FTP server. At first i thought some error with my script, but even individually if i run a mkdir in the ftp server its showing create directory failed. Can somebody let me know the possible error, or if any eror in my code that i am missing out on.The pwd is working fine though, which means there is no problem loging in the ftp site through script.

提前感谢您的帮助

推荐答案

看看expect

让你开始的东西

#!/usr/bin/expect

set timeout 120
spawn ftp 192.168.0.210
expect "Name"
send "root
"
expect "Password:"
send "pass
"
expect "ftp> "
send "bye
"

这篇关于用于自动执行 ftp 操作的 linux 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆