Sponsored Content
Full Discussion: FTP script
Top Forums Shell Programming and Scripting FTP script Post 44349 by CarlosManjarres on Thursday 4th of December 2003 03:18:30 PM
Old 12-04-2003
Perhaps you are asking for a script to trasnfer a file using FTP to an FTP server (local or remote).

If so, I would create 2 files:

1) .ftp_put.cfg
2) ftp_trasnsfer.ksh script

Note that I have removed the login parameters from the script.
This way you can modify the login parameter to point to any server without modifying the actual ftp script.

.ftp_put.cfg
-----------------------
FTP_HOST=your.host.com
FTP_LOGIN=your_account
FTP_PASSWORD=your_password

ftp_transfer.ksh
-----------------------
#!/bin/ksh

localFile=$1
remoteFile=$2

#source FTP parameters
. .ftp_put.cfg

mylog=ftp_session.log
echo "$(date "+%H:%M:%S") - Attempt to FTP $1 to $2" > $mylog

# do the FTP put

ftp -i -n <<EOF >> $mylog
open $FTP_HOST
user $FTP_LOGIN $FTP_PASSWORD
put $localFile $remoteFile
ls $remoteFile
quit
EOF


Warning!! This script does not have any transfer verification logic.


usage sample:

ftp_transfer.ksh readme.txt /pub/dir1/readme.txt
 

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
netrc(4)						     Kernel Interfaces Manual							  netrc(4)

NAME
netrc, .netrc - Specifies automatic login information for ftp SYNOPSIS
$HOME/.netrc DESCRIPTION
The .netrc file contains the information used by the automatic login (autologin) feature of the ftp command. It is a hidden file in your home directory and must be owned by the user logging in, or by the root user. If the .netrc file contains a login password, the file's permissions must be set to 600 (read and write by owner only). The .netrc file can contain the following entries (separated by spaces, tabs, or newlines): Where host is the name of a remote host. This entry begins the definition of the autologin process for the specified host. All following entries up to the next machine entry or the end of the file apply to that host. This is the same as machine, except that default matches any name. There can be only one default token, and it must appear after all machine tokens. This is normally used as follows: default login anonymous password user@site The preceding command line gives the user automatic anonymous ftp login to machines not specified in .netrc. This can be overriden by using the -n flag to disable autologin. Where user is the username to use at the remote host. If this entry is found, the autologin process initiates a login using the specified name. If this entry is missing, the autologin process fails. Where password is the login password to be used. The autologin process supplies this password to the remote server. A login password must be established at the remote host and that pass- word must be entered in this file, or the autologin process fails and you are prompted for the login password. Where password is the account password to be used. If this entry is found and an account password is required at the remote host, the autologin process supplies the password to the remote server. If the remote host requires an account password but this entry is missing, the autologin process prompts for the account password. Where macro is the name of an ftp subcommand macro. The macro definition starts on the following line and is defined to contain all of the following ftp subcommands up to the next blank line. If the macro is named init, ftp executes the macro upon successful completion of the autologin process. FILES
Contains automatic login information. RELATED INFORMATION
Commands: ftp(1). delim off netrc(4)
All times are GMT -4. The time now is 09:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy