Sponsored Content
Full Discussion: FTP script
Top Forums Shell Programming and Scripting FTP script Post 302168757 by prasanth_babu on Tuesday 19th of February 2008 10:57:32 AM
Old 02-19-2008
Dear,

I have come up with the same in different logic.the details of the same mentioned below;

1.Execute_FTP.sh : Main Script which will carry out the functionality of FTP.
2.Parser.sh :IP USERNAME PASSWORD SOURCE FILENAME
3.Upload.sh : FTP Environment Commands .


Execute_FTP.sh

./Parser.sh 10.132.207.2 onm onm /home/smvdba/Prasanth/OUT DiskAlert.txt /tmp/Alert/VDS

Parser.sh

set -x

if [ $# != 6 ]; then
echo "Usage
./Parser.sh IP USERNAME PASSWORD SOURCE FILENAME DESTINATION
where
IP ------------- IP address of remote server
USERNAME-------- username with which to establish ftp session
PASSWORD-------- password for the above mentioned USERNAME
SOURCE --------- source directory
FILENAME ------- name of the file to be ftped
DESTINATION----- path at remote directory at which file is to be kept"
exit
fi

HOME=/home/smvdba/Prasanth/OUT
DIRECTORY=$4
LOG=$HOME/LOG
EXPECTED_RETURN="221 Goodbye."
LIST_OF_FILES=list_of_files
cd $DIRECTORY
ls -lrt $5* >$LIST_OF_FILES

cat $LIST_OF_FILES|while read LINE
do
filename=`echo $LINE|awk '{print $9}'`
size=`echo $LINE|awk '{print $5}'`
if [ "$filename" = "" ]; then
filename=temp

elif [ "$filename" = "_" ]; then
filename=temp

else
echo "Transfering $filename"
sh $HOME/upload.sh $filename $1 $2 $3 $6 >$LOG/ftp_log
RETURN=`fgrep "221 Goodbye." $LOG/ftp_log`

if [ "$RETURN" = "${EXPECTED_RETURN}" ]

then
mv $DIRECTORY/$filename $DIRECTORY/FTPED/$filename
else
echo "Unable to establish connection"
fi

fi
done

Upload.sh


FILE=$1
IP=$2
USER=$3
PASS=$4
DESTINATION=$5
#cd OUTPUT/CIRCLE2
ftp -inv $IP<< !EOF
user $USER $PASS
cd $DESTINATION
prompt
asc
put $FILE Temp_$FILE
rename Temp_$FILE $FILE
quit
!EOF


Best Regards!
Prasanth Babu.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP script in Unix shell script

Hello , I am trying to make a shell script (Unix) for a ftp connection to another server and to get a file. So I have no knowledge about ftp and my script must do automaticly the connection with the user and passwd. Can you help us about that... Christian... (2 Replies)
Discussion started by: steiner
2 Replies

2. UNIX for Dummies Questions & Answers

excuting a shell script within ftp script

Novice here... I need help with excuting a shell script on a flat file that I've transfered over from a Windows XP machine for manipulation through an auto FTP script... so that after it is transfers it excutes the shell script and then returns it back to XP machine... Any ideas... (2 Replies)
Discussion started by: Gerry405
2 Replies

3. Shell Programming and Scripting

Need help - script for ftp..

I have my ftp script as below.. This is logging the messages into ftp.log file , But I want the same output(what ever messages are going into ftp.log) to be printed on the console too for the user to show the status.. Tried with "tee" .. unable to get the solution.. Can some one help me... (3 Replies)
Discussion started by: Srini75
3 Replies

4. Shell Programming and Scripting

FTP script to FTP file to UNIX - Solaris

Hello, A couple of times per week, i receive emails notifications when files are available for processing. Currently i read these eamails with a java program and store the attachement on my C: drive and would now like to generate a PC script to send this file name up to UNIX-Solaris and... (3 Replies)
Discussion started by: bobk544
3 Replies

5. Shell Programming and Scripting

ftp script not able to connect to ftp server.

I have the following ftp script to get files from a remote location. However, on running the script I find that I am not even able to connect to ftp server. I am able to connect to ftp server using other GUI ftp tools like WS_FTP using the same IP. IP used here is a dummy IP. What can go... (3 Replies)
Discussion started by: gram77
3 Replies

6. Shell Programming and Scripting

passing parameter to ftp script from output of another ftp

Hi, I have a ftp script which first gets all the file names and echo's the latest file. I'm using another ftp command sets to get the file name given by first ftp. The problem is the parameter is not accepted by second ftp. The error message i'm getting is > Rename Temp File calloc:ICMP... (5 Replies)
Discussion started by: ammu
5 Replies

7. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

8. Linux

Need SCP script equivalent to FTP script .

Hi, Currently i'm using the folllowing FTP acript and its working. echo "open $server" > ftp_file echo "user $user $password" >> ftp_file echo "cd $remote_dir" >> ftp_file echo "lcd $local_dir" >> ftp_file echo "put $file">> ftp_file echo "bye" >> ftp_file ftp -nv < ftp_file I've... (1 Reply)
Discussion started by: vickramshetty
1 Replies

9. Shell Programming and Scripting

Need help in ftp script

hello , I am working on a FTP script which navigates to specific directory and pulls the file Issue which i am facing :: ---------------------------- i) When there is a file it pulls the file , but when there is not file in the directory it fails in the same statement and it is not... (3 Replies)
Discussion started by: ranga27
3 Replies

10. Shell Programming and Scripting

configuration for ftp script in main script

Hi, I am new to shell scripting,and i was planning to write a script that will FTP files to destination folder. I was planning that All configuration should be done through a properties files. and finally the output should be Files are transferred I have developed a properties file named... (4 Replies)
Discussion started by: rahul125
4 Replies
ncftpls(1)						      General Commands Manual							ncftpls(1)

NAME
ncftpls - Internet file transfer program for scripts SYNOPSIS
ncftpls [options] ftp://url.style/host/path/name/ OPTIONS
Command line flags: -1 Most basic format, one item per line. -l Long list format. -R Long list format, recurse subdirectories. Equivalent to "-x -lR". -x -XX Additional ls flags to pass on to the server. -u XX Use username XX instead of anonymous. -p XX Use password XX with the username. -P XX Use port number XX instead of the default FTP service port (21). -d XX Use the file XX for debug logging. -t XX Timeout after XX seconds. -E Use regular (PORT) data connections. -F Use passive (PASV) data connections. The default is to use passive, but to fallback to regular if the passive connection fails or times out. -r XX Redial a maximum of XX times until connected to the remote FTP server. -W XX Send raw FTP command XX after logging in. -X XX Send raw FTP command XX after each file transferred. -Y XX Send raw FTP command XX before logging out. The -W, -X, and -Y options are useful for advanced users who need to tweak behavior on some servers. For example, users accessing mainframes might need to send some special SITE commands to set blocksize and record format information. For these options, you can use them multiple times each if you need to send multiple commands. For the -X option, you can use the cookie %s to expand into the name of the file that was transferred. DESCRIPTION
The purpose of ncftpls is to do remote directory listings using the File Transfer Protocol without entering an interactive shell. This lets you write shell scripts or other unattended processes that can do FTP. The default behavior is to print the directory listing in columnized format (i.e. ls -CF), but that is not very useful for scripting. This example uses the -1 flag, to print one file per line: $ ncftpls -1 ftp://ftp.ncftp.com/pub/ncftp/ You can also do a remote "ls -l", by using "ncftpls -l". If you want to try other flags, you have to use them with the -x flag. For exam- ple, if you wanted to do a remote "ls -lrt", you could do this: $ ncftpls -x "-lrt" ftp://ftp.ncftp.com/pub/ncftp/ By default the program tries to open the remote host and login anonymously, but you can specify a username and password information like you can with ncftpget or ncftpput. DIAGNOSTICS
ncftpls returns the following exit values: 0 Success. 1 Could not connect to remote host. 2 Could not connect to remote host - timed out. 3 Transfer failed. 4 Transfer failed - timed out. 5 Directory change failed. 6 Directory change failed - timed out. 7 Malformed URL. 8 Usage error. 9 Error in login configuration file. 10 Library initialization failed. 11 Session initialization failed. AUTHOR
Mike Gleason, NcFTP Software (mgleason@ncftp.com). SEE ALSO
ncftpput(1), ncftpget(1), ncftp(1), ftp(1), rcp(1), tftp(1). LibNcFTP (http://www.ncftp.com/libncftp/). Software NcFTP ncftpls(1)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy