The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Adding Multiple Lines to Multiple Files dayinthelife Shell Programming and Scripting 2 06-04-2008 11:50 AM
Multiple search in multiple files maxvirrozeito Shell Programming and Scripting 2 12-13-2007 01:32 PM
Dynamically ftp'ing a file pyaranoid UNIX for Advanced & Expert Users 0 09-02-2007 07:34 AM
FTP'ing files with filenames in mail messege berlin_germany Shell Programming and Scripting 1 11-27-2006 05:07 PM
Searching multiple files with multiple expressions Anahka Shell Programming and Scripting 6 01-07-2004 06:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-28-2006
berlin_germany berlin_germany is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 17
Help in FTP'ing multiple files

Hi,
I have written the following FTP script to get the multiple files from remote server to local server. My problem is that 'mget *' is not working in the script. I also tried with 'mget *.txt', 'mget *.*' etc. without any success. It do not copy any file to local server. In the script, Prompt is set off. However, when I try doing it manually, it works. Don't know, where the problem lies. My code is like,

$LOGIN=user
$FTPPASS=password
mkdir ftp`date '+%Y%m%d'`
cd ftp`date '+%Y%m%d'`

`ftp -vin <<- END_INPUT > $LOG/ftp_files.log 2>&1
open $DEVICE
user $LOGIN $FTPPASS
cd $PICKUP
mget *.txt
quit
END_INPUT`
  #2 (permalink)  
Old 11-29-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
Your ftp log files might have the information,
have you looked into that ?
  #3 (permalink)  
Old 11-29-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
you should have used "prompt" command before executing"mget" command
  #4 (permalink)  
Old 11-29-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
Hi,

can you try this code and let me know
this is working fine , i checked it

Code:
HOME1=/home/sri
echo " 1"

ftp -n server_ip << END_INPUT > /tmp/ftp_files.log 2>&1
user username password
cd $HOME1
prompt
mget *.txt
bye
END_INPUT
  #5 (permalink)  
Old 11-29-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
The op had obtained the same effect
having the
Code:
-i option
in ftp
  #6 (permalink)  
Old 11-29-2006
berlin_germany berlin_germany is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 17
Thanks a lot Srikanthus2002. I did as you mentioned and it's working fine when I try to FTP files in a directory "ftp`date '+%Y%m%d'`" on local server. But, when I try to ftp the same files to one more directory "ftp_verify`date '+%Y%m%d'`" on the local server using 'lcd' command, it do not copy anything there. Actually, to check wether files are FTP'ed correctly on local server, I need to use a verification logic in my script. And to do that I copy files from remote server in 2 different directories on local server and then compare them using 'diff' command in the script. Then after verification I delete the verification directory "ftp_verify`date '+%Y%m%d'`". Can you please explain, why it's not copying files in "ftp_verify`date '+%Y%m%d'`" directory? My scripts is like:

#!/bin/ksh
HOME1=/home/sri
echo " 1"

cd /home
mkdir ftp`date '+%Y%m%d'`
mkdir ftp_verify`date '+%Y%m%d'`
cd ftp`date '+%Y%m%d'`

ftp -n server_ip << END_INPUT > /tmp/ftp_files.log 2>&1
user username password
cd $HOME1
prompt
mget *.txt # copies files correctly
lcd /tmp/ftp_verify`date '+%Y%m%d'`
mget *.txt # Do not copy anything
bye
END_INPUT

cd /home
diff -w ftp`date '+%Y%m%d'` ftp_verify`date '+%Y%m%d'` > /dev/null

if [ $? -ne 0 ]
then
echo "Error: Files are not successfully FTP'd"
mailx -r user@vrfai030.private.annonymous.com -s \'"Files FTP failed'" user@annonymous.com < /tmp/ftp_fail.msg
exit 1
rm -r ftp_verify`date '+%Y%m%d'`

fi
exit 0
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0