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
Passing the values to the secondary script when it invoked by primary script venu_eie UNIX for Advanced & Expert Users 2 07-03-2008 08:10 AM
Passing the values to the secondary script when it invoked by primary script venu_eie Shell Programming and Scripting 1 07-03-2008 07:16 AM
create a shell script that calls another script and and an awk script magikminox Shell Programming and Scripting 0 06-26-2008 03:50 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 04:06 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-09-2008
draco draco is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 38
FTP script - Need a little help here with it.

Hi there all..

I have the following.
I have a FTP someware where raports are put on.
I have to FTP to it and get them in and than delete the remote
But all the time there are new files put in, so I dont want to delete after I copy, becouse than I can delete files that are not yet copyed.
And it is kinda sensetive information as in no body will be able to read it but it better not get deleted withoud getting a copy on this side.

I build this script, and well it is getting the files but it is not putting the files to the correct local dir. and I disabled the mdelete function for now, so I dont loose files, but I want to use that the same as the mget.

Code:
#!/usr/bin/ksh
#
 set -x 
 
## VARIABLES##
 
RNODE="192.168.10.30"
USER="*****"
PASSWD="********"
LOCALDIR="/glims/mgnt/mmpamm"
REMOTEDIR=""
DIRLISTFILE="${LOCALDIR}/${RNODE}.$(basename ${REMOTEDIR}).dirlist.out"
cat /dev/null > $DIRLISTFILE
 
HISTLOG=/glims/mgnt/mmpamm/logs/ftphist.log
FTPLOG=/glims/mgnt/mmpamm/logs/ftptrans.log
glimspad=/glims/mgnt/mmpamm
ERROR_FILE=/glims/mgnt/mmpamm/errorfile
HOSTNAME=`uname -n`
 
## DEFINE FUNCTIONS HERE ##
 
 
######### Check if there is an error file #########
function errorfile_check
{
 if test -r $ERROR_FILE
 then
  rm $ERROR_FILE
 fi
}
######### Ping check if host is avalible #########
function ping_check
{
 ping $RNODE -n 2 > $glimspad/pingctrl.txt
 PINGCTRL=`cat $glimspad/pingctrl.txt | wc -l`
}
######### ERROR report #########
function report_ERROR
{
 echo `date '+%d %b %H:%M:%S'` $RNODE NIET gevonden >> $HISTLOG 2>&1
 echo stop `date '+%d %b %H:%M:%S'` >> $HISTLOG 2>&1
 touch $ERROR_FILE
 echo `date '+%d %b %H:%M:%S'` "communicatie PC: $RNODE" >> $ERROR_FILE
 echo "Let op !!!!!" >> $ERROR_FILE
 echo ""  >> $ERROR_FILE
 echo "Fout tijdens overdracht PAMM" >> $ERROR_FILE
 exit
}
######### File check from host (FTP) #########
function file_check_host
{
 ftp -i -v -n 192.168.10.30 <<END_FTP
 user $USER $PASSWD
 nlist $REMOTEDIR $DIRLISTFILE
 bye
 
END_FTP
}
######### File Copy from host (FTP) #########
function file_copy_host
{
 ftp -i -v -n 192.168.10.30 <<END_FTP
 
 user $USER $PASSWD
 lcd $LOCALDIR
 cd $REMOTEDIR
 mget $DIRLISTFILE
 bye
 
END_FTP
}
######### File Remove from host (FTP) #########
function file_remove_host
{
 ftp -i -v -n $RNODE <<END_FTP
 
 user $USER $PASSWD
# mdelete 
 bye
 
END_FTP
}
 
## BEGINNING OF MAIN ##
 
 
errorfile_check
ping_check
 
if  pingctrl=7 
then
 file_check_host
sleep 5
 file_copy_host
sleep 5
 file_remove_host
fi
# End of script
 

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 10:12 PM.


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