Shell FTP script to send all files to different path


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell FTP script to send all files to different path
# 1  
Old 09-22-2012
Shell FTP script to send all files to different path

Hello to all in forum

I hope you can help me.

I want to send via FTP to a linux server the 2 kind of files that are in the same folder, as follow:

1- Send all files that are named verified.SomeString.zz.pttp to path /var/verified
2- Send all files where the name begins with verified.conf to path/etc

PD: I have the IP address, user and password of the server.

Any help would be appreciatted.

Regards
# 2  
Old 09-22-2012
I assume your host is also Unix or similar OS.
Try something like..

Code:
cd to/the/directory
ftp -ivn XX.XXX.XXX.XXX <<END
cd /var/verified
put verified.*.zz.pttp
cd  /etc
ascii
put verified.conf
bye
END

If the *pttp are also ascii file, place the ascii before the first put.

Although its not tested but you can have idea of how to ftp.
# 3  
Old 09-25-2012
Hello clx, many thanks for your help,

For some reason the user and password didnt work or something,
bur finally works for me combining your solution with another script I found and
using mput in order to be able to use wildcards too.

Code:
#!/bin/bash -xv
USER='user'
PASSWD='password'

ftp -in <<EOD
open X.X.X.X
quote USER $USER
quote PASS $PASSWD
bin
cd /etc
mput verified.conf*
bin
cd /var/named
mput verified.*.pttp
quit
EOD
#exit 0

Best regards
# 4  
Old 09-25-2012
Sorry, I forgot to provide user/password line in the code.
It should be like this

Code:
cd to/the/directory
ftp -ivn XX.XXX.XXX.XXX <<END
user $USER $PASSWD
cd /var/verified
put verified.*.zz.pttp
cd  /etc
ascii
put verified.conf
bye
END

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Locating shell script files with the $PATH variable

I've created a test script, which is located in $HOME/bin. The script runs as expected with no issues. However, upon echo'ing the $path variable the location of my script is not located in any of the directories listed in $path. So my question is, how does shell know where the script is located... (2 Replies)
Discussion started by: BrandonD
2 Replies

2. Shell Programming and Scripting

shell script to ftp multiple files

Hi, i use the below script to send a single file to remote server from linux. ftp -nvi <<!EOF open $Host_name user $USER_ID $PWD binary mput $file_name quit !EOF (where i... (2 Replies)
Discussion started by: pradebban
2 Replies

3. Emergency UNIX and Linux Support

Shell script to get all the files from FTP server

Hi Guru's, I am new to UNIX. my requirement is to log on to FTP server and get all the .txt files. i have developed one script by searching some forums but getting error and not able to fix them. pls see below code. ftp -i-n<<EOF open $FTP_HOST... (30 Replies)
Discussion started by: arund_01
30 Replies

4. Shell Programming and Scripting

How to write a shell script to display files in single path?

Hello friends, I am a script which dispalys a multiple files with their contents. for exm: suppose two file test1.txt and test2.txt. when I run my script it have to display the below O/P. test1.txt -rw-r----- 1 sranga staff 91 Sep 23 02:18 calc.sh -rw-r----- 1 sranga ... (2 Replies)
Discussion started by: sivaranga001
2 Replies

5. UNIX for Dummies Questions & Answers

ftp files from one server to another using shell script

Hi Guys Any Help I have created a spool file that i need to copy onto another server using FTP in a shell script both servers are linux (3 Replies)
Discussion started by: itai
3 Replies

6. Shell Programming and Scripting

Getting a list of files on an ftp, via shell script...

G'day, I was wanting to write a shell script that checks an ftp server for the presence of new files, then get those files. In so much as the get, this is pretty straight forward, but I cannot work out how to get a list of files to check. Is it possible for a shell script to get the output of... (1 Reply)
Discussion started by: Elric of Grans
1 Replies

7. Shell Programming and Scripting

how to send multiple files from the shell script

hi, how to send multiple files from the shell script eg : i have /home/adm/file1 /home/adm/file2 /home/adm/cfg how can i attach these files in the mail ? (1 Reply)
Discussion started by: mail2sant
1 Replies

8. Shell Programming and Scripting

Recursive call to find files and directories in Shell script from current path.

################################################################ Copy this script to your path from where you want to search for all the files and directories in subdirectories recursively. ################################################################# code starts here... (2 Replies)
Discussion started by: Ramit_Gupta
2 Replies

9. Shell Programming and Scripting

Random files do not FTP in the shell script

The following script is used to loop through files in the /tmp directory and transfer those files onto another server. However, some of the files do not transfer. It is very random when the transferring is done (i.e. one of the files won't transfer then next time, that one will transfer and... (1 Reply)
Discussion started by: RLatham20
1 Replies

10. Shell Programming and Scripting

ftp files inside a shell script

I have a shell script where I am trying to ftp some files but I get the error message "EOF unclosed" every time the script reaches the ftp section. Here is how my script is written. #more code up here rm -f $object >> $LOG_FILE 2>&1 fi #end of if done #end of for loop ... (5 Replies)
Discussion started by: matrix1067
5 Replies
Login or Register to Ask a Question