LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Connection, login and upload files to ftp server via shell script (https://www.linuxquestions.org/questions/linux-networking-3/connection-login-and-upload-files-to-ftp-server-via-shell-script-148493/)

Paulo Góes 02-20-2004 03:07 PM

Connection, login and upload files to ftp server via shell script
 
In my network there are:

Machine A (ftp server running ProFTPd)
Machine B

In Machine B, at /root, there is .netrc file that controls successfully auto-login to Machine A. From the command line the connection and login are fine, but how can I do to, via shell script, execute the connection, login and upload some files as I do interactively in command line?

Thanks in advance
Paulo Góes

linuxxed 02-21-2004 12:25 PM

Re: Connection, login and upload files to ftp server via shell script
 
Quote:

Originally posted by Paulo Góes
In my network there are:

Machine A (ftp server running ProFTPd)
Machine B

In Machine B, at /root, there is .netrc file that controls successfully auto-login to Machine A. From the command line the connection and login are fine, but how can I do to, via shell script, execute the connection, login and upload some files as I do interactively in command line?

Thanks in advance
Paulo Góes

1)One way is to write like this.

ftp server<<EOF

ftp command 1
ftp command 2
.......
bye
EOF

There shouldn't be iany leading space before the last EOF. You can use any string in place of EOF.

2) Second way is

(ftp command1 ; sleep 1; ftp command 2 ; sleep 1; ftp command 3; sleep 1 )| ftp server



This should work fine . Note the "sleeps" .. they are added to give the server some time to respond. The only problem is it sends it as a bunch to the server and if the server is slow then it may not work correctly(1%).

3) Third way is to use TCL expect. Expect allows you to automate anything. It's brilliant.

dominant 02-21-2004 01:01 PM

Try to do your job using perl is pretty simple with Net::FTP module!


All times are GMT -5. The time now is 08:27 PM.