linux script to automate ftp operation

后端 未结 4 1690
梦谈多话
梦谈多话 2020-12-20 08:13

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

My shell script is :

    #! /bin/ksh

    HOST=\'my_ip\'
    USER=\'userid\'
    PASS         


        
相关标签:
4条回答
  • 2020-12-20 08:43

    Probably lftp ( ftp scripting client ) will be something you need ( look among your distro's packages ). Error creating directories is probably related to permissions of the dir inside which you try to create it.

    http://lftp.yar.ru/desc.html

    0 讨论(0)
  • 2020-12-20 08:58

    Have a look at expect

    Something to get you started

    #!/usr/bin/expect
    
    set timeout 120
    spawn ftp 192.168.0.210
    expect "Name"
    send "root\r"
    expect "Password:"
    send "pass\r"
    expect "ftp> "
    send "bye\r"
    
    0 讨论(0)
  • 2020-12-20 08:59

    Have you tried using SCP (Secure Copy)?

    scp -r /dir/to/"file.txt" username@hostname

    *if you're in the directory of the file/folder you wish to send then you don't need to define the complete filepath

    Have a look at this article if you want to scp without having to enter your password. http://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/

    0 讨论(0)
  • 2020-12-20 08:59

    If you are root or have admin privileges then you shouldn't need to sudo your way into making a directory. It will be best to run remote commands without sudo just in case a malicious code piggybacks your script

    0 讨论(0)
提交回复
热议问题