linux - Persistent non-interactive FTP session for usage in shell scripts -
i script complex scenario of file transfers linux windows ftp server (detecting new/changed files , transfer) , unable find command-line ftp client supports sending files on persistent (one time login) session on non-interactive mode.
ssh/scp
password-less authentication not option, since have no access windows ftp server.
for example using lftp
`lftp -u user,pass -p 21 -e "mput newfile.txt;"` 10.0.0.100
will upload file server, requires authentication/handshaking happen on every request, takes long time , severely slows down transfers.
i wondering whether there way authenticate once, establish persistent connection , sending files on connection. lftp
, other clients able in interactive mode (connect , perform multiple commands until quitting).
therefore:
- is there ftp client on linux may operate in non-interactive mode?
- alternatively, there way simulate behaviour, scripting on interactive mode? maybe utilizing
expect
netcat/telnet
and/or named pipes?
untested, can tcl:
package require ftp set conn [ftp::open server user pass] while true { after 5000 ;# sleep 5 seconds foreach newfile [glob -nocomplain *] { puts "sending $newfile" ftp::put $newfile file delete $newfile } }
the expect similar. untested:
set timeout -1 spawn lftp -u user,pass server expect "> " while true { sleep 5 foreach newfile [glob -nocomplain *] { puts "sending $newfile" send "put $newfile\r" expect "> " file delete $newfile } send "\r" ;# "hit enter" keep-alive }
Comments
Post a Comment