Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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'
    PASSWD='password'
    FILE='file.txt'
    DIREC='/eir_log'
    ftp -in $HOST << EOMYF 
    user $USER $PASSWD
    binary
    mkdir $DIREC 
    cd $DIREC
    pwd
    quit
    EOMYF

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.

Thanks in advance for your help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

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
"
expect "Password:"
send "pass
"
expect "ftp> "
send "bye
"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...