FTP multiple files from remote server to local server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP multiple files from remote server to local server
Prev   Next
# 1  
Old 12-13-2006
FTP multiple files from remote server to local server

Hi,

I am facing a weired problem in my FTP script. I want to transfer multiple files from remote server to local server everyday, using mget * in my script. I also, want to send an email for successful or failed FTP. My script works for file transfer, but it don't send any mail. There is somthing wrong with mailx option, I don't know what.

If I use the FTP part of the script like below, mailx works fine, but then mget is not working (only get is working) and no files are transfered.

`ftp -vin <<- END_INPUT > $LOG/ftp_files.log 2>&1
open $DEVICE
user $LOGIN $FTPPASS
cd $PICKUP
prompt off
mget *.txt
quit
END_INPUT`

The original script is below:

#!/bin/ksh

export DROPOFF=/data/local/temp
export PICKUP=/data/remote/temp
export MSG=/data/local/temp
export IND_FILE=/data/local/temp
export LOG=/data/local/temp
export LOGIN=username
export FTPPASS=password
export DEVICE=remoteserver

cd $DROPOFF

ftp -vin <<- END_INPUT > $LOG/ftp_files.log 2>&1
open $DEVICE
user $LOGIN $FTPPASS
cd $PICKUP
prompt off
mget *.txt
quit
END_INPUT
EXIT_STATUS=$?


if [ $EXIT_STATUS -ne 0 ]
then
echo "[%s - %s]ERROR: FTP failed with an exit status of %s\n" \
%0 "$(date +'%x %X')" $EXIT_STATUS
mailx -r mlqis4s@server.private.company.com -s \'"Files FTP failed'" user@company.com < $MSG/ftp_fail.msg
exit 1
fi
echo mailx -r mlqis4s@server.private.company.com -s \'"Files FTP successful'" user@company.com < $MSG/ftp_succ.msg

exit 0

Please anybody have a clue to solve that? Thanks in advance!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep remote multiple hosts output to local server

Hello all, i'm trying to create a report by greping a pattern on multiple remote hosts and creta a simple report, actually i did this, is ther any better way to do this. #!/bin/bash for host in `cat RemoteHosts` do ssh $host -C 'hostname 2>&1; grep ERROR /var/log/WebServer.log.2019-09-21... (0 Replies)
Discussion started by: charli1
0 Replies

2. UNIX for Advanced & Expert Users

Best way to transfer files to remote FTPS server instead of local FTPS server

Hi, I am working on an application which runs on an Informatica Red-Hat 5.10 Linux Server. The application involves several Informatica ETL workflows which generate 100s of Text files with lot of data. Many of the files will each be up to 5 GB in size. Currently the Informatica server itself... (7 Replies)
Discussion started by: waavman
7 Replies

3. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

4. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

5. UNIX for Dummies Questions & Answers

How to copy files from remote server to local?

Hi experts, I 'm newbie to unix world, now I have task to copy the latest files from remote server to my local. I believe this must be very common request in this community. I want you do it one more time for me please. My requirement is something like this: I receive files in the below... (3 Replies)
Discussion started by: parpaa
3 Replies

6. UNIX for Dummies Questions & Answers

compare zip files from a local to remote server

Good evening I need your help pease I know there are 2 commands(diff, or cp) to compare files in a directory. but the question arises: 1. can i compare zip files or ive got to unzip them? 2. how can i compare 2 files from a local to a remote server? (is there any special commad or ive got... (4 Replies)
Discussion started by: alexcol
4 Replies

7. Shell Programming and Scripting

FTP files from different directory from remote server to one directory in local

Hi All, I want to search for .log files from folders and sub folders in remote server and FTP them to one particular folder in the local machine. I dont want to copy the entire directory tree structure, just have to take all the .log files from all the folders by doing a recursive search from the... (3 Replies)
Discussion started by: dassv
3 Replies

8. Shell Programming and Scripting

ftp'ing multiple files to the remote server

unix shell script (2 Replies)
Discussion started by: giridhar276
2 Replies

9. Shell Programming and Scripting

preserving the timestamp of a file when copied from remote server to local server using ftp

Hi, I need to copy few files from remote server to local server. I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed. ... (5 Replies)
Discussion started by: arunkumarmc
5 Replies

10. Shell Programming and Scripting

Can a script runned in local server access remote server?

Hi, Im creating a script that is supposed to run commands on remote server using sftp. My script is as below: #!/bin/ksh sftp remote_server mypassword cd /u08/mydir/allfiles mget * .. But this is what I got when I runned the script: Connecting to remote server...... (3 Replies)
Discussion started by: luna_soleil
3 Replies
Login or Register to Ask a Question